:root {
  color-scheme: light;
  --bg: #f4f6f3;
  --surface: #ffffff;
  --ink: #18211f;
  --muted: #65716d;
  --line: #d9e0dc;
  --accent: #136f63;
  --accent-strong: #0d594f;
  --warm: #b96028;
  --danger: #b3261e;
  --shadow: 0 16px 40px rgba(24, 33, 31, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

.app-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(28px, 5vw, 42px);
  letter-spacing: 0;
}

h2 {
  margin-bottom: 5px;
  font-size: 20px;
}

p {
  color: var(--muted);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.batch-panel {
  display: grid;
  grid-template-columns: 1.3fr 1fr 0.8fr 0.8fr;
  gap: 14px;
  padding: 18px;
  margin-bottom: 18px;
}

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

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfb;
  color: var(--ink);
  outline: none;
}

input {
  min-height: 42px;
  padding: 8px 10px;
}

textarea {
  margin-top: 14px;
  padding: 12px;
  resize: vertical;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(19, 111, 99, 0.12);
}

.workspace {
  display: grid;
  grid-template-columns: 330px 1fr;
  gap: 18px;
}

.upload-panel,
.table-panel,
.sign-panel {
  padding: 18px;
}

.upload-box {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 172px;
  border: 1.5px dashed #9eb0aa;
  border-radius: 8px;
  background: #f8faf8;
  cursor: pointer;
}

.upload-box.dragging {
  border-color: var(--accent);
  background: #eef8f5;
}

.upload-box input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.upload-copy {
  display: grid;
  gap: 8px;
  text-align: center;
  padding: 18px;
}

.upload-copy strong {
  font-size: 18px;
}

.upload-copy span,
.status {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 14px 0;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  padding: 9px 14px;
  cursor: pointer;
  transition: transform 0.16s ease, background 0.16s ease, opacity 0.16s ease;
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.primary-btn {
  background: var(--accent);
  color: white;
  font-weight: 700;
}

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

.secondary-btn {
  background: var(--warm);
  color: white;
  font-weight: 700;
}

.ghost-btn {
  border: 1px solid var(--line);
  background: #f7f9f8;
  color: var(--ink);
}

.danger {
  color: var(--danger);
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 14px;
}

.preview-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: white;
}

.preview-card img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
}

.preview-card span {
  display: block;
  padding: 8px;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.section-head p {
  margin-bottom: 0;
  font-size: 13px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 8px;
  text-align: left;
  vertical-align: middle;
}

th {
  background: #f1f5f3;
  color: #3d4b47;
  font-size: 13px;
  font-weight: 700;
}

td:first-child,
th:first-child {
  width: 54px;
  text-align: center;
}

td:last-child,
th:last-child {
  width: 56px;
}

td input {
  min-height: 36px;
  padding: 6px 8px;
}

.delete-row {
  width: 36px;
  min-height: 36px;
  padding: 0;
  color: var(--danger);
}

.summary-row {
  display: flex;
  justify-content: flex-end;
  align-items: baseline;
  gap: 12px;
  margin-top: 14px;
  color: var(--muted);
}

.summary-row strong {
  color: var(--accent);
  font-size: 24px;
}

.sign-panel {
  margin-top: 18px;
}

canvas {
  display: block;
  width: 100%;
  height: 220px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  touch-action: none;
}

@media (max-width: 880px) {
  .topbar,
  .section-head {
    flex-direction: column;
    align-items: stretch;
  }

  .batch-panel,
  .workspace {
    grid-template-columns: 1fr;
  }

  .preview-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 18px, 1180px);
    padding-top: 16px;
  }

  .panel {
    box-shadow: none;
  }

  .preview-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
