:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  background: #f4f6f8;
  color: #17202a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
}

button,
input,
select,
textarea {
  font: inherit;
}

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

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

.eyebrow {
  color: #667085;
  font-size: 13px;
  margin: 0 0 4px;
}

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

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

h2 {
  font-size: 18px;
  margin-bottom: 6px;
}

h4 {
  font-size: 15px;
  margin: 18px 0 8px;
}

.user-chip {
  align-items: center;
  background: #ffffff;
  border: 1px solid #e4e7ec;
  border-radius: 8px;
  display: flex;
  gap: 8px;
  padding: 8px 12px;
}

.avatar {
  align-items: center;
  background: #12715b;
  border-radius: 50%;
  color: #ffffff;
  display: inline-flex;
  height: 28px;
  justify-content: center;
  width: 28px;
}

.workspace {
  align-items: start;
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1fr) 460px;
}

.contract-management {
  background: #ffffff;
  border: 1px solid #e4e7ec;
  border-radius: 8px;
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
  padding: 16px;
}

.contract-management h2 {
  margin-bottom: 4px;
}

.contract-management p {
  color: #667085;
  font-size: 14px;
  margin-bottom: 0;
}

.management-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

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

.contract-card {
  align-items: center;
  background: #f8fafc;
  border: 1px solid #e4e7ec;
  border-radius: 8px;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 12px;
}

.contract-card strong {
  display: block;
  margin-bottom: 4px;
}

.contract-meta {
  color: #667085;
  font-size: 13px;
}

.contract-empty {
  color: #667085;
  font-size: 14px;
  padding: 8px 0;
}

.contract-card button {
  min-width: 88px;
}

.contract-form,
.preview-panel {
  background: #ffffff;
  border: 1px solid #e4e7ec;
  border-radius: 8px;
  padding: 20px;
}

.preview-panel {
  position: sticky;
  top: 16px;
}

.form-section {
  border-bottom: 1px solid #eef2f6;
  margin-bottom: 20px;
  padding-bottom: 18px;
}

.form-section:last-of-type {
  border-bottom: 0;
}

.section-title p {
  color: #667085;
  font-size: 14px;
  margin-bottom: 18px;
}

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

label {
  color: #344054;
  display: grid;
  font-size: 14px;
  font-weight: 700;
  gap: 8px;
  margin-bottom: 16px;
}

input,
select,
textarea {
  background: #ffffff;
  border: 1px solid #d0d5dd;
  border-radius: 6px;
  color: #17202a;
  min-height: 42px;
  padding: 10px 12px;
  width: 100%;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #16866d;
  box-shadow: 0 0 0 3px rgba(22, 134, 109, 0.14);
  outline: none;
}

.grid-2,
.grid-3 {
  display: grid;
  gap: 14px;
}

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

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

.segmented {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 14px;
}

.segmented label {
  align-items: center;
  background: #f8fafc;
  border: 1px solid #d0d5dd;
  border-radius: 6px;
  display: flex;
  flex-direction: row;
  gap: 8px;
  margin: 0;
  min-height: 42px;
  padding: 10px 12px;
}

.segmented input {
  min-height: auto;
  width: auto;
}

.product-table {
  border: 1px solid #e4e7ec;
  border-radius: 8px;
  overflow: hidden;
}

.product-head,
.product-row {
  display: grid;
  gap: 8px;
  grid-template-columns: 1.2fr 1fr 0.7fr 0.8fr 44px;
  padding: 10px;
}

.product-head {
  background: #f8fafc;
  color: #667085;
  font-size: 13px;
  font-weight: 700;
}

.product-row {
  border-top: 1px solid #eef2f6;
}

.product-row input {
  min-height: 38px;
}

.icon-button {
  align-items: center;
  background: #fee4e2;
  border: 0;
  border-radius: 6px;
  color: #b42318;
  display: inline-flex;
  font-size: 18px;
  font-weight: 700;
  justify-content: center;
}

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

button {
  cursor: pointer;
}

.primary,
.secondary {
  border: 0;
  border-radius: 6px;
  font-weight: 700;
  min-height: 42px;
  padding: 0 16px;
}

.primary {
  background: #12715b;
  color: #ffffff;
}

.secondary {
  background: #eef2f6;
  color: #344054;
}

.full {
  width: 100%;
}

.stack-button {
  margin-bottom: 10px;
}

.paper {
  background: #fbfcfd;
  border: 1px solid #e4e7ec;
  border-radius: 8px;
  line-height: 1.7;
  padding: 20px;
}

.paper h3 {
  font-size: 20px;
  text-align: center;
}

.doc-row {
  display: flex;
  font-size: 13px;
  justify-content: space-between;
  margin-bottom: 6px;
}

.summary-table {
  border-collapse: collapse;
  font-size: 13px;
  margin-bottom: 10px;
  width: 100%;
}

.summary-table th,
.summary-table td {
  border: 1px solid #d0d5dd;
  padding: 6px;
  text-align: center;
}

.summary-table th {
  background: #f8fafc;
}

.total-line {
  margin-bottom: 4px;
}

.paragraph,
.party-box {
  background: #ffffff;
  border-left: 3px solid #12715b;
  font-size: 13px;
  margin-bottom: 10px;
  padding: 10px 12px;
  white-space: pre-wrap;
}

.party-box {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr 1fr;
}

.party-box p {
  margin-bottom: 0;
}

.approval-box {
  background: #f8fafc;
  border: 1px solid #e4e7ec;
  border-radius: 8px;
  margin-top: 16px;
  padding: 16px;
}

.approval-box div {
  align-items: center;
  display: flex;
  gap: 8px;
}

.approval-box p {
  color: #667085;
  font-size: 14px;
  margin: 8px 0 14px;
}

.compact-label {
  font-size: 13px;
  margin-bottom: 10px;
}

.login-note {
  color: #667085;
  font-size: 12px;
  line-height: 1.5;
  margin: -4px 0 10px;
}

.approval-history {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.approval-item {
  background: #ffffff;
  border: 1px solid #e4e7ec;
  border-radius: 6px;
  color: #344054;
  font-size: 13px;
  padding: 8px 10px;
}

.approval-item strong {
  color: #17202a;
}

.status-dot {
  background: #98a2b3;
  border-radius: 50%;
  display: inline-block;
  height: 10px;
  width: 10px;
}

.status-dot.is-submitted {
  background: #12715b;
}

.toast {
  background: #17202a;
  border-radius: 8px;
  bottom: 18px;
  color: #ffffff;
  left: 50%;
  opacity: 0;
  padding: 10px 14px;
  pointer-events: none;
  position: fixed;
  transform: translate(-50%, 14px);
  transition: 0.2s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 1000px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .preview-panel {
    order: -1;
    position: static;
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 14px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .grid-2,
  .grid-3,
  .segmented,
  .party-box,
  .contract-card {
    grid-template-columns: 1fr;
  }

  .product-head {
    display: none;
  }

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

  .actions,
  .row-title {
    flex-direction: column;
  }

  .actions button,
  .row-title button,
  .management-actions button,
  .contract-card button {
    width: 100%;
  }
}
