﻿* {
  box-sizing: border-box;
}

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

.page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.panel {
  width: min(980px, 100%);
  padding: 32px;
  background: #ffffff;
  border: 1px solid #dde3ee;
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(32, 33, 36, 0.08);
}

h1 {
  margin: 0 0 8px;
  font-size: 32px;
}

.intro {
  margin: 0 0 24px;
  color: #5f6368;
}

.upload-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.upload-box {
  display: grid;
  gap: 8px;
  min-height: 170px;
  padding: 24px;
  border: 2px dashed #98a8bd;
  border-radius: 8px;
  background: #fbfcff;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.2s;
}

.upload-box:hover {
  border-color: #1a73e8;
  background: #f1f6ff;
  transform: translateY(-2px);
}

.upload-box.drag-over {
  border-color: #1a73e8;
  background: #e8f1ff;
  box-shadow: 0 0 0 4px rgba(26, 115, 232, 0.12);
}

.upload-icon {
  width: 64px;
  padding: 8px 0;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  color: #ffffff;
  background: #1f7a4d;
  border-radius: 6px;
}

.upload-box:nth-child(2) .upload-icon {
  background: #315fba;
}

.upload-title {
  font-size: 20px;
  font-weight: 700;
}

.upload-text {
  color: #697386;
}

input[type="file"] {
  width: 100%;
}

.file-list,
.tenant-section,
.preview-section,
.contract-list-section {
  margin-top: 24px;
  padding: 18px;
  border-radius: 8px;
  background: #f8fafc;
}

.file-list h2,
.tenant-section h2,
.preview-section h2,
.contract-list-section h2 {
  margin: 0 0 10px;
  font-size: 20px;
}

.file-list p {
  margin: 8px 0;
}

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

#tenantCount,
#previewStatus,
#contractListStatus {
  color: #5f6368;
  font-size: 14px;
}

.table-wrap {
  overflow-x: auto;
}

.empty-text {
  margin: 8px 0 0;
  color: #697386;
}

table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  background: #ffffff;
}

th,
td {
  padding: 12px;
  border: 1px solid #dbe3ef;
  text-align: left;
  vertical-align: top;
}

th {
  color: #ffffff;
  background: #255f85;
  font-weight: 700;
  white-space: nowrap;
}

td {
  color: #263238;
}

tbody tr:nth-child(even) {
  background: #f7fbff;
}

.contract-preview {
  min-height: 220px;
  max-height: 460px;
  overflow: auto;
  margin: 8px 0 0;
  padding: 18px;
  border: 1px solid #dbe3ef;
  border-radius: 8px;
  white-space: pre-wrap;
  line-height: 1.8;
  font-family: "Microsoft JhengHei", Arial, sans-serif;
  color: #263238;
  background: #ffffff;
}

.placeholder {
  display: inline-block;
  margin: 0 2px;
  padding: 1px 7px;
  border-radius: 6px;
  color: #7a3b00;
  background: #fff2cc;
  border: 1px solid #f3c36b;
  font-weight: 700;
}

.placeholder.applied {
  color: #0f5132;
  background: #d8f3dc;
  border-color: #95d5b2;
}

.preview-download-button {
  margin-top: 14px;
}

.contract-list {
  display: grid;
  gap: 10px;
  margin-top: 8px;
}

.contract-item {
  display: grid;
  grid-template-columns: 1fr 180px;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid #dbe3ef;
  border-radius: 8px;
  background: #ffffff;
}

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

.contract-item button {
  margin-top: 0;
  padding: 10px 12px;
  font-size: 16px;
}

button {
  width: 100%;
  margin-top: 20px;
  padding: 14px 18px;
  border: 0;
  border-radius: 8px;
  font-size: 18px;
  font-weight: 700;
  color: #ffffff;
  background: #1a73e8;
  cursor: pointer;
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 20px;
}

.action-grid button {
  margin-top: 0;
}

button:disabled {
  color: #6b7280;
  background: #d9dee7;
  cursor: not-allowed;
}

.message {
  min-height: 24px;
  margin: 14px 0 0;
  color: #4b5563;
}

.message.success {
  color: #147a42;
  font-weight: 700;
}

.message.error {
  color: #b42318;
  font-weight: 700;
}

@media (max-width: 700px) {
  .panel {
    padding: 22px;
  }

  h1 {
    font-size: 26px;
  }

  .upload-grid {
    grid-template-columns: 1fr;
  }

  .action-grid {
    grid-template-columns: 1fr;
  }

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

  .section-title-row {
    align-items: flex-start;
    flex-direction: column;
  }
}
