:root {
  font-family: "Noto Sans TC", "Source Han Sans TC", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  color: #1f2937;
  background: #f5f7fb;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
}

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 38px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 0 14px;
  color: #1f2937;
  background: #ffffff;
  cursor: pointer;
}

button:hover:not(:disabled) {
  border-color: #64748b;
}

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

.primary-button {
  border-color: #0f766e;
  color: #ffffff;
  background: #0f766e;
}

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

.toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 26px 0 20px;
}

.eyebrow {
  margin: 0 0 6px;
  color: #0f766e;
  font-size: 13px;
  font-weight: 700;
}

h1 {
  margin: 0;
  color: #111827;
  font-size: 32px;
  line-height: 1.2;
  letter-spacing: 0;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.sync-time {
  min-width: 190px;
  margin: 0;
  color: #64748b;
  font-size: 13px;
  text-align: right;
}

.controls {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  padding: 18px;
  border: 1px solid #dbe3ef;
  border-radius: 8px;
  background: #ffffff;
}

.search-field {
  display: grid;
  gap: 7px;
  flex: 1;
  max-width: 420px;
  color: #475569;
  font-size: 13px;
  font-weight: 700;
}

.search-field input {
  width: 100%;
  min-height: 40px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 0 12px;
  color: #111827;
  background: #ffffff;
}

.batch-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}

.summary-strip div {
  padding: 16px 18px;
  border: 1px solid #dbe3ef;
  border-radius: 8px;
  background: #ffffff;
}

.summary-strip span {
  display: block;
  color: #111827;
  font-size: 26px;
  font-weight: 800;
}

.summary-strip small {
  color: #64748b;
  font-size: 13px;
}

.employee-list {
  display: grid;
  gap: 12px;
}

#employeeRows {
  display: grid;
  gap: 12px;
}

.employee-card {
  overflow: hidden;
  border: 1px solid #dbe3ef;
  border-radius: 8px;
  background: #ffffff;
}

.employee-card-header {
  display: grid;
  grid-template-columns: auto minmax(220px, 1fr) auto minmax(180px, auto) auto;
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
}

.employee-summary {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.employee-summary strong {
  color: #111827;
  font-size: 16px;
}

.employee-summary span,
.employee-summary small {
  overflow: hidden;
  color: #64748b;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.employee-editor {
  display: grid;
  gap: 18px;
  padding: 16px;
  border-top: 1px solid #e5eaf2;
  background: #fbfdff;
}

.editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(460px, 520px);
  gap: 18px;
  align-items: start;
}

.editor-fields {
  display: grid;
  gap: 18px;
}

.editor-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  color: #475569;
  font-size: 12px;
  font-weight: 800;
}

.positions-editor {
  display: grid;
  gap: 10px;
}

.positions-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.positions-toolbar strong {
  color: #111827;
}

.position-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  padding: 10px;
  border: 1px solid #dbe3ef;
  border-radius: 8px;
  background: #ffffff;
}

.position-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.icon-button {
  min-width: 58px;
}

.table-input,
.table-textarea {
  width: 100%;
  border: 1px solid #d4dce8;
  border-radius: 6px;
  color: #111827;
  background: #ffffff;
}

.table-input {
  min-height: 34px;
  padding: 0 9px;
}

.strong-input {
  font-weight: 800;
}

.table-textarea {
  min-height: 62px;
  resize: vertical;
  padding: 8px 9px;
  line-height: 1.45;
}

.table-input:focus,
.table-textarea:focus {
  border-color: #0f766e;
  outline: 2px solid rgb(15 118 110 / 16%);
}

.contact-edit {
  display: grid;
  gap: 8px;
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 120px;
  color: #334155;
  font-size: 13px;
  font-weight: 700;
}

.checkbox-field input {
  width: 16px;
  height: 16px;
  accent-color: #0f766e;
}

.edited-card {
  background: #fbfdfa;
}

.status-list {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.pill.ok {
  color: #047857;
  background: #d1fae5;
}

.pill.warn {
  color: #92400e;
  background: #fef3c7;
}

.pill.block {
  color: #b91c1c;
  background: #fee2e2;
}

.download-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.inline-pdf-preview {
  position: sticky;
  top: 16px;
  display: grid;
  gap: 10px;
  min-width: 0;
}

.inline-preview-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.inline-preview-header strong {
  display: block;
  color: #111827;
}

.inline-preview-header span,
.inline-preview-status {
  color: #64748b;
  font-size: 12px;
  font-weight: 700;
}

.inline-preview-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.inline-preview-actions button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.inline-preview-actions button.active {
  border-color: #0f766e;
  color: #ffffff;
  background: #0f766e;
}

.inline-preview-frame-wrap {
  display: grid;
  min-height: 620px;
  overflow: hidden;
  border: 1px solid #d7dee9;
  border-radius: 6px;
  background: #ffffff;
  box-shadow: 0 12px 24px rgb(15 23 42 / 8%);
}

.inline-preview-frame {
  width: 100%;
  height: 620px;
  border: 0;
  background: #ffffff;
}

.empty-state {
  display: grid;
  min-height: 160px;
  place-items: center;
  border: 1px solid #dbe3ef;
  border-radius: 8px;
  background: #ffffff;
  color: #64748b;
  text-align: center;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100% - 36px));
  border-radius: 8px;
  padding: 12px 14px;
  color: #ffffff;
  background: #111827;
  box-shadow: 0 18px 38px rgb(15 23 42 / 20%);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.preview-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgb(15 23 42 / 58%);
}

.preview-modal[hidden] {
  display: none;
}

.preview-dialog {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(1280px, 100%);
  height: min(880px, calc(100vh - 36px));
  overflow: hidden;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 28px 80px rgb(15 23 42 / 32%);
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid #e2e8f0;
}

.preview-header h2 {
  margin: 0;
  color: #111827;
  font-size: 18px;
  line-height: 1.3;
  letter-spacing: 0;
}

.preview-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.preview-frame {
  width: 100%;
  height: 100%;
  border: 0;
  background: #f8fafc;
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding: 18px 0;
  }

  .toolbar,
  .controls,
  .toolbar-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .sync-time {
    min-width: 0;
    text-align: left;
  }

  .search-field {
    max-width: none;
  }

  .batch-actions {
    justify-content: stretch;
  }

  .batch-actions button {
    flex: 1 1 180px;
  }

  .summary-strip {
    grid-template-columns: 1fr;
  }

  .employee-card-header,
  .editor-grid,
  .editor-layout,
  .position-row {
    grid-template-columns: 1fr;
  }

  .inline-pdf-preview {
    position: static;
  }

  .inline-preview-frame-wrap {
    min-height: 420px;
  }

  .inline-preview-frame {
    height: 420px;
  }

  .download-actions {
    justify-content: stretch;
  }

  .download-actions button {
    flex: 1 1 120px;
  }

  .preview-modal {
    padding: 10px;
  }

  .preview-dialog {
    height: calc(100vh - 20px);
  }

  .preview-header {
    align-items: stretch;
    flex-direction: column;
  }

  .preview-actions button {
    flex: 1 1 140px;
  }
}
