.history-backfill-page .history-upload-shell { margin-bottom: 18px; }

.history-upload-footer {
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding-top: 2px;
}

.history-upload-footer .submission-upload-footer-actions {
  margin-left: auto;
}

.history-head-actions {
  gap: 14px;
}

.history-library-entry {
  min-height: 42px;
  border-radius: 14px;
  padding: 9px 16px;
  background: rgba(255, 252, 246, .9);
  font-weight: 900;
  white-space: nowrap;
}

.history-new-project-entry {
  min-height: 42px;
  border-radius: 14px;
  padding: 9px 16px;
  font-weight: 900;
  white-space: nowrap;
}

.history-library-entry .material-symbols-outlined {
  font-size: 18px;
}

.history-new-project-entry .material-symbols-outlined {
  font-size: 18px;
}

.history-library-file {
  text-decoration: none;
}

.history-invoice-table-entry {
  border-color: rgba(74, 124, 89, .36);
  background: rgba(200, 232, 208, .18);
  color: var(--primary);
}

.history-library-file-wrap .file-explorer-delete {
  opacity: 1;
}

.history-library-file .file-explorer-meta:last-child {
  color: var(--primary);
  font-weight: 900;
}

.history-invoice-table-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(46, 50, 48, .28);
  backdrop-filter: blur(4px);
}

.history-invoice-table-dialog {
  width: min(980px, calc(100vw - 64px));
  max-height: min(720px, calc(100vh - 72px));
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border: 1px solid rgba(196, 200, 188, .58);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(46, 50, 48, .18);
}

.history-invoice-table-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(250, 248, 243, .86);
}

.history-invoice-table-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.history-invoice-table-head h3 {
  margin-top: 6px;
  color: var(--primary);
  font-size: 22px;
  line-height: 1.25;
  font-weight: 900;
}

.history-invoice-table-head p {
  margin-top: 7px;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}

.history-invoice-table-wrap {
  min-height: 0;
  overflow: auto;
  padding: 18px;
}

.history-invoice-detail-table {
  min-width: 860px;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}

.history-invoice-detail-table th {
  background: rgba(200, 232, 208, .24);
  color: var(--primary);
  font-weight: 900;
}

.history-invoice-detail-table td,
.history-invoice-detail-table th {
  font-size: 13px;
}

.history-invoice-detail-table td b {
  color: var(--text);
  font-weight: 900;
}

.history-invoice-table-empty {
  height: 140px;
  text-align: center;
  color: var(--muted);
  font-weight: 800;
}

.history-backfill-task-section {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.history-backfill-task-list .processing-task {
  min-height: 176px;
}

.history-backfill-result-card {
  grid-column: span 12;
  border-radius: 24px;
}

.history-invoice-step {
  grid-template-columns: minmax(0, 1fr);
  padding: 0;
  border-top: 1px solid var(--line);
  border-radius: inherit;
  background: #fff;
}

.submission-task-modal .history-backfill-result-card {
  height: auto;
  min-height: 0;
  overflow: hidden;
  border-radius: 24px;
}

.submission-task-modal .history-backfill-batch-result-card {
  height: min(680px, calc(100vh - 260px));
  min-height: 520px;
}

.submission-task-modal .history-invoice-step {
  height: auto;
  min-height: 0;
  overflow: visible;
  align-content: start;
  scrollbar-width: thin;
}

.submission-task-modal .history-batch-confirm-step {
  grid-template-columns: minmax(300px, 36%) minmax(0, 1fr);
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.history-batch-sidebar {
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  justify-items: stretch;
  align-content: stretch;
  text-align: left;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 14px;
  padding: 18px;
}

.history-batch-summary {
  min-width: 0;
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  padding: 12px;
  border: 1px solid rgba(120, 168, 134, .26);
  border-radius: 16px;
  background: rgba(255, 255, 255, .72);
}

.history-batch-summary .file-preview-card {
  width: 62px;
  height: 82px;
  justify-self: center;
}

.history-batch-summary .file-preview-card .material-symbols-outlined {
  font-size: 31px;
}

.history-batch-summary .file-preview-card span {
  bottom: 18px;
  font-size: 6px;
}

.history-batch-summary .file-preview-card b {
  min-width: 24px;
  height: 24px;
  font-size: 9px;
}

.history-batch-summary div:last-child {
  min-width: 0;
}

.history-batch-summary span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
  font-weight: 900;
}

.history-batch-summary strong {
  display: block;
  margin-top: 4px;
  color: var(--text);
  font-size: 15px;
  line-height: 1.35;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.history-batch-summary p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  font-weight: 800;
}

.history-batch-file-list {
  max-height: 100%;
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 8px;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 2px 4px 2px 0;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.history-batch-file-list::-webkit-scrollbar {
  width: 8px;
}

.history-batch-file-list::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(120, 168, 134, .42);
}

.history-batch-file-item {
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: 32px 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 10px;
  border: 1px solid rgba(196, 200, 188, .48);
  border-radius: 14px;
  background: rgba(255, 255, 255, .78);
  color: var(--text);
  text-align: left;
}

.history-batch-file-item:hover {
  border-color: rgba(120, 168, 134, .42);
  background: #fff;
}

.history-batch-file-item.selected {
  border-color: rgba(74, 124, 89, .48);
  background: rgba(200, 232, 208, .22);
  box-shadow: 0 8px 22px rgba(62, 80, 61, .08);
}

.history-batch-file-index {
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(46, 50, 48, .08);
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.history-batch-file-item.selected .history-batch-file-index {
  background: var(--primary);
  color: #fff;
}

.history-batch-file-item > .material-symbols-outlined {
  color: var(--primary);
  font-size: 21px;
}

.history-batch-file-main {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.history-batch-file-main b {
  color: var(--text);
  font-size: 13px;
  line-height: 1.25;
  font-weight: 900;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-batch-file-main em {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  font-style: normal;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-batch-file-item small {
  justify-self: end;
  border-radius: 999px;
  padding: 4px 8px;
  background: rgba(74, 124, 89, .12);
  color: var(--primary);
  font-size: 11px;
  line-height: 1;
  font-weight: 900;
  white-space: nowrap;
}

.history-backfill-confirm-panel .wizard-progress {
  padding-right: 255px;
}

.history-backfill-project-identity .history-backfill-project-name {
  color: var(--primary);
  font-family: "Literata", "Microsoft YaHei", serif;
  font-size: 18px;
}

.history-backfill-folder-field .input {
  color: var(--text);
}

.history-backfill-invoice-panel {
  gap: 18px;
  padding: 0;
  overflow: visible;
  min-height: 0;
  height: auto;
  grid-template-rows: auto auto auto;
  position: relative;
  border-radius: inherit;
}

.submission-task-modal .history-backfill-invoice-panel {
  height: auto;
  min-height: 0;
  overflow: visible;
}

.history-invoice-list {
  display: grid;
  gap: 30px;
  min-height: 0;
  padding: 26px 36px 112px;
  box-sizing: border-box;
}

.history-invoice-summary-pill {
  display: flex;
  align-items: center;
  min-height: 72px;
  padding: 16px 300px 16px 24px;
  border-bottom: 1px solid var(--line);
}

.history-invoice-summary-pill span {
  display: inline-flex;
  width: fit-content;
  border-radius: 999px;
  padding: 8px 14px;
  background: rgba(229, 116, 40, .12);
  color: #7a4a1d;
  font-size: 13px;
  font-weight: 900;
}

.history-invoice-confirm-panel {
  box-sizing: border-box;
  width: 100%;
  min-height: 360px;
  border: 1px solid rgba(120, 168, 134, .46);
  border-radius: 24px;
  margin: 0;
  padding: 34px 36px 38px;
  overflow: visible !important;
  background: #fff;
  align-content: start;
}

.submission-task-modal .history-invoice-confirm-panel {
  position: relative;
  min-height: 360px;
  overflow: visible !important;
  padding: 34px 36px 38px;
  border-radius: 24px;
  align-content: start;
}

.submission-task-modal .history-invoice-confirm-panel + .history-invoice-confirm-panel {
  margin-top: 0;
}

.history-invoice-confirm-panel .invoice-confirm-head h4 {
  font-size: 22px;
  margin-top: 12px;
}

.history-invoice-confirm-panel .invoice-confirm-head p {
  margin-top: 6px;
  color: var(--text);
  font-size: 15px;
  font-weight: 400;
  line-height: 1.45;
}

.history-invoice-confirm-panel .invoice-confirm-grid {
  gap: 20px 22px;
  box-sizing: border-box;
  margin-top: 20px;
}

.history-invoice-confirm-panel .invoice-field {
  min-width: 0;
  box-sizing: border-box;
  border-radius: 8px;
  padding: 20px;
  align-content: start;
}

.history-invoice-confirm-panel .invoice-field .input {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  border-radius: 8px;
}

.history-invoice-confirm-panel .invoice-confirm-actions {
  padding-top: 18px;
}

.history-backfill-invoice-panel .history-backfill-wizard-actions {
  top: 16px;
  right: 32px;
  align-items: center;
  gap: 12px;
}

.submission-task-modal .history-backfill-invoice-panel .history-backfill-wizard-actions {
  top: 16px;
  right: 58px;
}

.history-backfill-invoice-panel .history-backfill-wizard-actions .btn {
  min-height: 42px;
  border-radius: 14px;
  padding-inline: 22px;
}

@media (max-width: 900px) {
  .history-upload-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .submission-task-modal .history-batch-confirm-step {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(260px, 42vh) minmax(0, 1fr);
  }

  .submission-task-modal .history-backfill-batch-result-card {
    height: auto;
    min-height: 0;
  }

  .history-batch-sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .history-batch-file-item {
    grid-template-columns: 30px 26px minmax(0, 1fr);
  }

  .history-batch-file-item small {
    display: none;
  }

  .history-backfill-confirm-panel .wizard-progress {
    padding-right: 0;
  }
}

.history-project-table-count {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

.history-project-preview-card {
  grid-template-columns: 240px 1.2fr 1fr;
  position: sticky;
  left: 0;
  width: min(1560px, calc(100vw - 120px));
}

/* ===== 手机端适配（仅 ≤760px 小屏生效，不影响桌面端） ===== */
@media (max-width: 760px) {
  .history-head-actions { flex-wrap: wrap; }
  .history-library-entry, .history-new-project-entry { white-space: normal; }
  .history-invoice-table-overlay { padding: 10px; }
  .history-invoice-table-dialog { width: calc(100vw - 20px); max-height: calc(100dvh - 20px); }
  .history-invoice-table-head { flex-wrap: wrap; padding: 16px; }
  .history-invoice-table-wrap { padding: 12px; }
  .history-invoice-detail-table { min-width: 640px; }
  .history-invoice-summary-pill { padding: 12px 16px; }
  .history-invoice-list { padding: 16px 12px 96px; }
  .history-invoice-confirm-panel,
  .submission-task-modal .history-invoice-confirm-panel { padding: 20px 14px 24px; }
  .history-backfill-invoice-panel .history-backfill-wizard-actions,
  .submission-task-modal .history-backfill-invoice-panel .history-backfill-wizard-actions { right: 14px; }
  .history-batch-sidebar { padding: 12px; }
  .history-project-preview-card { grid-template-columns: 1fr; width: calc(100vw - 40px); }
}

.history-approval-badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 12px; white-space: nowrap; }
.history-approval-badge .material-symbols-outlined { font-size: 15px; }
.history-approval-badge.ready { background: #e6f4ea; color: #1e7d3c; }
.history-approval-badge.missing { background: #fdecea; color: #c62828; font-weight: 600; }

.history-project-detail-panel .panel-head h3 { display: inline-flex; align-items: center; gap: 6px; }
.history-project-detail-panel .panel-head h3 .material-symbols-outlined { font-size: 19px; color: var(--brand, #2e6b3f); }

.history-project-table-inline { margin-top: 14px; }
.history-project-table-inline .history-project-archive-page { padding: 0; }
.history-detail-editable { cursor: pointer; }
.history-detail-editable:hover { background: rgba(46, 107, 63, .05); border-radius: 10px; }
.history-detail-editable i.history-detail-edit-hint { width: auto; height: auto; display: inline; background: none; border-radius: 0; font-size: 14px; margin-left: 4px; opacity: 0; color: var(--muted, #7a8a7f); vertical-align: -2px; }
.history-detail-editable:hover .history-detail-edit-hint { opacity: 1; }
.history-detail-edit-input { width: 100%; margin-top: 2px; font-size: 13px; }
.history-project-table-inline .archive-weekly-table { max-height: calc(100dvh - 300px); }

/* 历史回填页全宽布局：项目表左右撑满屏幕 */
body:has(.history-backfill-page) #page-root.page { max-width: none; padding-left: 20px; padding-right: 20px; }
.history-page.history-backfill-page { max-width: none; margin: 0; }

/* 项目表单元格与系统一相同：固定行数截断，行高一致；完整内容看预览卡/详情页 */

/* 发票明细表可编辑单元格 */
.history-invoice-editable { cursor: pointer; }
.history-invoice-editable .history-detail-edit-hint { font-size: 13px; margin-left: 4px; opacity: 0; color: var(--muted, #7a8a7f); vertical-align: -2px; }
.history-invoice-editable:hover .history-detail-edit-hint,
.history-invoice-editable:focus-visible .history-detail-edit-hint { opacity: 1; }
.history-invoice-editable:hover { background: rgba(200, 232, 208, .22); }

/* 历史文件重命名按钮沿用系统一样式，位置在删除按钮左侧 */
.history-library-file-wrap .file-explorer-rename { right: 44px; }

/* 历史回填项目表：页面允许滚动，避免最后一行被视口裁掉（系统一的 archive-page 会锁死 body 滚动） */
body:has(.history-backfill-page) { height: auto; overflow: auto; }
body:has(.history-backfill-page) #page-root.page { height: auto; overflow: visible; }
.history-project-table-inline .history-project-archive-page { height: auto; display: block; }
.history-project-table-inline .archive-weekly-table { max-height: calc(100dvh - 220px); }
