:root {
  color-scheme: light;
  /* 设计基准见项目根目录 DESIGN.md（暖米白 + 深绿，源自 awesome-design-md 的 Starbucks 设计系统） */
  --bg: #f2f0eb;
  --card: #ffffff;
  --text: rgba(0, 0, 0, 0.87);
  --muted: rgba(0, 0, 0, 0.58);
  --green: #006241;
  --primary: #00754a;
  --primary-dark: #006241;
  --house: #1e3932;
  --green-light: #d4e9e2;
  --gold: #cba258;
  --gold-lightest: #faf6ee;
  --border: #e7e7e7;
  --input-border: #d6dbde;
  --red: #c82014;
  --yellow: #fbbc05;
  --shadow: 0 0 0.5px rgba(0, 0, 0, 0.14), 0 1px 1px rgba(0, 0, 0, 0.24);
  --shadow-nav: 0 1px 3px rgba(0, 0, 0, 0.1), 0 2px 2px rgba(0, 0, 0, 0.06), 0 0 2px rgba(0, 0, 0, 0.07);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  letter-spacing: -0.01em;
}

button,
input,
select,
textarea {
  font-family: inherit;
  letter-spacing: inherit;
}

.page {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 32px 24px 64px;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
  padding: 28px 32px;
  border-radius: 12px;
  background: var(--house);
  box-shadow: var(--shadow-nav);
}

h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.2;
  color: #fff;
}

.header h1::before {
  content: "";
  display: block;
  width: 28px;
  height: 3px;
  margin-bottom: 10px;
  border-radius: 999px;
  background: var(--gold);
}

.sub {
  margin: 8px 0 0;
  color: rgba(255, 255, 255, 0.7);
  font-size: 14px;
}

.card {
  background: var(--card);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 20px;
  padding: 24px;
  margin-bottom: 24px;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

label {
  font-size: 13px;
  color: var(--muted);
}

input[type="date"] {
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--input-border);
  border-radius: 4px;
  background: #fff;
  color: var(--text);
  font-size: 14px;
}

input[type="date"]:focus,
.form-grid input:focus,
.edit-item-row input:focus,
.edit-item-row select:focus {
  border-color: var(--primary);
  outline: none;
}

.quick-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  padding: 0 18px;
  border: 0;
  border-radius: 50px;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn:active {
  transform: scale(0.95);
}

.btn.primary {
  background: var(--primary);
  color: #fff;
}

.btn.primary:hover {
  background: var(--primary-dark);
}

.header .btn.primary {
  background: #fff;
  color: var(--primary);
}

.header .btn.primary:hover {
  background: var(--green-light);
  color: var(--primary-dark);
}

.btn.ghost {
  background: transparent;
  border: 1px solid var(--primary);
  color: var(--primary);
}

.btn.ghost:hover {
  background: var(--green-light);
  color: var(--primary-dark);
}

.summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.summary-card {
  padding: 22px;
  background: var(--card);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.summary-card .label {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
}

.summary-card strong {
  font-size: 26px;
  font-weight: 600;
  color: var(--green);
}

/* 总金额卡片：深绿底 + 金色数字，全站唯一的仪式感点缀 */
.summary-card:nth-child(2) {
  background: var(--house);
}

.summary-card:nth-child(2) .label {
  color: rgba(255, 255, 255, 0.7);
}

.summary-card:nth-child(2) strong {
  color: var(--gold);
}

.list h2 {
  margin: 0 0 16px;
  font-size: 20px;
  color: var(--green);
}

.records {
  display: grid;
  gap: 16px;
}

.record-card {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 20px;
  padding: 20px;
  background: var(--card);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.record-card.no-image {
  grid-template-columns: 1fr;
}

.record-image {
  width: 100%;
  height: 160px;
  object-fit: cover;
  border-radius: 12px;
  background: #f2f0eb;
}

.record-pdf-preview {
  display: block;
  width: 100%;
  height: 160px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #f9f9f9;
  overflow: hidden;
}

.record-main {
  min-width: 0;
}

.record-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
}

.record-title {
  margin: 0;
  font-size: 18px;
}

.record-amount {
  font-size: 18px;
  font-weight: 700;
  color: var(--green);
}

.record-meta {
  margin: 10px 0 14px;
  color: var(--muted);
  font-size: 13px;
}

.record-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.items {
  display: grid;
  gap: 8px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.item {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 12px;
  background: #f2f0eb;
  border-radius: 8px;
  font-size: 14px;
}

.item span:last-child {
  font-weight: 600;
}

.empty {
  padding: 40px;
  border: 1px dashed var(--input-border);
  border-radius: 12px;
  text-align: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.6);
}

@media (max-width: 720px) {
  .page {
    padding: 20px 16px 48px;
  }

  .header {
    align-items: flex-start;
    flex-direction: column;
    padding: 24px;
  }

  .record-card {
    grid-template-columns: 1fr;
  }

  .record-image {
    height: 200px;
  }

  .record-pdf-preview {
    height: 200px;
  }
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

.modal-overlay.hidden {
  display: none;
}

.modal {
  display: grid;
  grid-template-rows: auto 1fr;
  width: min(1080px, 100%);
  height: min(88vh, 900px);
  overflow: hidden;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 28px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  margin: 0;
  font-size: 22px;
  color: var(--green);
}

.modal-body {
  display: grid;
  grid-template-columns: 320px 1fr;
  min-height: 0;
  overflow: hidden;
}

.modal-original {
  padding: 24px;
  border-right: 1px solid var(--border);
  overflow: auto;
  background: #f9f9f9;
}

.modal-original h3,
.modal-form h3 {
  margin: 0 0 16px;
  font-size: 17px;
  color: var(--green);
}

.modal-original img {
  display: block;
  width: 100%;
  border-radius: 12px;
  background: #fff;
  cursor: zoom-in;
}

object a {
  color: var(--primary);
  font-weight: 600;
}

.original-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.original-actions .btn,
.original-actions a {
  height: 36px;
  padding: 0 12px;
  font-size: 13px;
}

.modal-form {
  min-height: 0;
  padding: 24px 28px 32px;
  overflow: auto;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}

.form-grid label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.form-grid input {
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--input-border);
  border-radius: 4px;
  color: var(--text);
  font-size: 14px;
  background: #fff;
}

.edit-items-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.edit-items {
  display: grid;
  gap: 12px;
  margin-bottom: 12px;
}

.edit-amount-warning {
  display: none;
  margin: 0 0 20px;
  padding: 12px 14px;
  border-left: 4px solid var(--yellow);
  border-radius: 8px;
  background: var(--gold-lightest);
  color: #92400e;
  font-size: 13px;
  line-height: 1.6;
}

.edit-amount-warning.visible {
  display: block;
}

.edit-item-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) 90px 100px 110px 42px;
  gap: 10px;
  align-items: center;
}

.edit-item-row input,
.edit-item-row select {
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--input-border);
  border-radius: 4px;
  color: var(--text);
  font-size: 14px;
  background: #fff;
}

.edit-item-row button {
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: rgba(200, 32, 20, 0.06);
  color: var(--red);
  font-weight: 700;
  cursor: pointer;
}

.edit-error {
  min-height: 20px;
  margin: 0 0 16px;
  color: var(--red);
  font-size: 13px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-bottom: 28px;
}

.modal-history {
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.history-item {
  padding: 14px;
  border-radius: 12px;
  background: #f9f9f9;
  font-size: 13px;
  line-height: 1.7;
}

.history-item + .history-item {
  margin-top: 10px;
}

@media (max-width: 820px) {
  .modal-body {
    grid-template-columns: 1fr;
    overflow: auto;
  }

  .modal-original {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .edit-item-row {
    grid-template-columns: 1fr;
  }
}

.preview-modal {
  display: grid;
  grid-template-rows: auto 1fr;
  width: min(1100px, 100%);
  height: min(92vh, 960px);
  overflow: hidden;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
}

.preview-header h2 {
  margin: 0;
  font-size: 20px;
  color: var(--green);
}

.preview-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.preview-actions .btn,
.preview-actions a {
  height: 36px;
  padding: 0 12px;
  font-size: 13px;
}

.preview-canvas {
  position: relative;
  overflow: hidden;
  background: var(--house);
}

.preview-image {
  position: absolute;
  top: 50%;
  left: 50%;
  max-width: 100%;
  max-height: 100%;
  transform-origin: center center;
  cursor: grab;
  user-select: none;
}

.preview-image:active {
  cursor: grabbing;
}

.delete-modal {
  display: grid;
  grid-template-rows: auto 1fr;
  width: min(680px, 100%);
  max-height: 80vh;
  overflow: hidden;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
}

.delete-body {
  padding: 28px;
  overflow: auto;
}

.delete-warning {
  margin: 0 0 24px;
  padding: 14px 16px;
  border-left: 4px solid var(--yellow);
  border-radius: 8px;
  background: var(--gold-lightest);
  color: #92400e;
  font-size: 14px;
  line-height: 1.7;
}

.btn.danger {
  background: var(--red);
  border: 0;
  color: #fff;
}

.btn.danger:hover {
  background: #a81a10;
}

.btn.danger:disabled {
  background: var(--red);
  color: #fff;
  opacity: 0.45;
  cursor: not-allowed;
}

.site-footer {
  margin-top: 32px;
  padding: 16px 0 24px;
  text-align: center;
}

.site-footer a {
  color: rgba(0, 0, 0, 0.58);
  font-size: 12px;
  text-decoration: none;
}

.site-footer a:hover {
  color: #006241;
}
