* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Microsoft JhengHei", Arial, sans-serif;
  color: #1f2937;
  background: #f4f7fb;
}

.page {
  width: min(1100px, calc(100% - 32px));
  margin: 32px auto;
}

.upload-area {
  padding: 32px;
  text-align: center;
  background: #ffffff;
  border: 2px dashed #8aa4c8;
  border-radius: 8px;
  transition: border-color 0.2s, background 0.2s;
}

.upload-area.dragging {
  border-color: #2563eb;
  background: #eef5ff;
}

.docx-area {
  margin-top: 18px;
}

.upload-icon {
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  margin: 0 auto 16px;
  color: #ffffff;
  font-weight: 700;
  background: #28734f;
  border-radius: 8px;
}

.docx-icon {
  background: #7c3aed;
}

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

h1 {
  margin-bottom: 8px;
  font-size: 28px;
}

.file-button {
  display: inline-block;
  margin-top: 12px;
  padding: 10px 18px;
  color: #ffffff;
  background: #2563eb;
  border-radius: 6px;
  cursor: pointer;
}

.docx-button {
  background: #7c3aed;
}

input[type="file"] {
  display: none;
}

.file-name {
  margin: 14px 0 0;
  color: #4b5563;
}

.result-area,
.contract-area,
.preview-area {
  margin-top: 24px;
}

.result-head {
  display: flex;
  gap: 16px;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 12px;
}

.result-head h2 {
  margin-bottom: 0;
  font-size: 22px;
}

#statusText {
  margin-bottom: 0;
  color: #6b7280;
}

.table-wrap,
.contract-wrap {
  min-height: 220px;
  overflow: auto;
  background: #ffffff;
  border: 1px solid #d7deea;
  border-radius: 8px;
}

.contract-wrap {
  padding: 24px;
  line-height: 1.8;
  white-space: pre-wrap;
}

.empty {
  padding: 48px 20px;
  text-align: center;
  color: #6b7280;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  min-width: 120px;
  padding: 10px 12px;
  text-align: left;
  white-space: nowrap;
  vertical-align: top;
  border: 1px solid #e5e7eb;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  font-weight: 700;
  background: #edf2f7;
}

tr:nth-child(even) td {
  background: #fafcff;
}

.variable {
  display: inline-block;
  padding: 0 4px;
  color: #7c2d12;
  font-weight: 700;
  background: #fed7aa;
  border-radius: 4px;
}

.missing-variable {
  display: inline-block;
  padding: 0 4px;
  color: #991b1b;
  font-weight: 700;
  background: #fecaca;
  border-radius: 4px;
}

.download-button {
  padding: 10px 18px;
  color: #ffffff;
  font: inherit;
  background: #0f766e;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}

.download-button:disabled {
  cursor: not-allowed;
  background: #9ca3af;
}

.batch-button {
  margin-bottom: 12px;
}

.tenant-list {
  display: grid;
  gap: 10px;
}

.tenant-item {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
}

.tenant-name {
  font-weight: 700;
}

@media (max-width: 640px) {
  .page {
    width: min(100% - 20px, 1100px);
    margin: 16px auto;
  }

  .upload-area {
    padding: 24px 16px;
  }

  h1 {
    font-size: 24px;
  }

  .result-head {
    display: block;
  }

  #statusText {
    margin-top: 6px;
  }
}
