:root {
  color-scheme: light;
  --bg: #f4f7f8;
  --panel: #ffffff;
  --ink: #172326;
  --muted: #66757a;
  --line: #dce5e7;
  --green: #16835d;
  --green-dark: #0f6b4b;
  --blue: #246bfe;
  --amber: #c57918;
  --shadow: 0 18px 40px rgba(19, 38, 44, 0.08);
  font-family:
    "Microsoft YaHei",
    "PingFang SC",
    system-ui,
    -apple-system,
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
}

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

button {
  cursor: pointer;
}

.sidebar {
  min-height: 100vh;
  padding: 24px 18px;
  background: #102429;
  color: #f4fbfc;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: #2fb98f;
  color: #06231b;
  display: grid;
  place-items: center;
  font-size: 22px;
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  margin-top: 4px;
  color: #b7c9cc;
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #d8e5e7;
  text-align: left;
  padding: 0 14px;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding-top: 18px;
  color: #b7c9cc;
  font-size: 13px;
  line-height: 1.5;
}

.sidebar-footer strong {
  color: #ffffff;
  display: block;
  margin-top: 8px;
  font-size: 14px;
}

.app {
  padding: 28px;
  min-width: 0;
}

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

.topbar h1,
.panel h2,
.mini-card h2 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: clamp(24px, 3vw, 34px);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 700;
}

.topbar-actions,
.sign-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.primary-button,
.secondary-button,
.ghost-button,
.icon-button {
  border: 1px solid transparent;
  border-radius: 8px;
  min-height: 42px;
  padding: 0 16px;
  font-weight: 700;
}

.primary-button {
  background: var(--green);
  color: #ffffff;
}

.primary-button:hover {
  background: var(--green-dark);
}

.secondary-button {
  background: #e8f4f1;
  color: var(--green-dark);
  border-color: #bcded4;
}

.ghost-button {
  background: #ffffff;
  color: var(--ink);
  border-color: var(--line);
}

.icon-button {
  width: 42px;
  padding: 0;
  background: #eef3f4;
  color: var(--ink);
}

.wide {
  width: 100%;
}

.dashboard-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.dashboard-strip div {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.dashboard-strip span {
  color: var(--muted);
  display: block;
  font-size: 13px;
}

.dashboard-strip strong {
  display: block;
  margin-top: 8px;
  font-size: 25px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.workspace-grid,
.phone-layout {
  display: grid;
  grid-template-columns: minmax(320px, 440px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

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

.panel {
  padding: 20px;
}

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

.panel-title h2 {
  font-size: 20px;
}

.status-pill {
  border-radius: 999px;
  background: #eef3f4;
  color: var(--muted);
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.status-pill.green {
  background: #e4f5ee;
  color: var(--green-dark);
}

.status-pill.blue {
  background: #e9efff;
  color: var(--blue);
}

.form-panel {
  display: grid;
  gap: 14px;
}

.storage-note {
  border: 1px solid #bcded4;
  border-radius: 8px;
  background: #f2faf7;
  color: #28574b;
  padding: 12px;
  line-height: 1.5;
  font-size: 13px;
  font-weight: 700;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(22, 131, 93, 0.14);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.payment-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.approver-editor {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.approver-head,
.approver-row {
  display: grid;
  grid-template-columns: 1.1fr 1fr 1fr;
  gap: 8px;
  align-items: center;
  padding: 9px;
}

.approver-head {
  background: #eef3f4;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.approver-row + .approver-row {
  border-top: 1px solid var(--line);
}

.approver-row strong {
  font-size: 13px;
}

.approver-row input {
  padding: 8px 9px;
}

.options {
  display: grid;
  gap: 10px;
}

.checkline {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  font-weight: 600;
}

.checkline input {
  width: 17px;
  height: 17px;
}

.document-preview {
  position: relative;
  min-height: 520px;
  border: 1px solid #cdd9dc;
  border-radius: 8px;
  background:
    linear-gradient(#ffffff, #ffffff) padding-box,
    repeating-linear-gradient(0deg, #ffffff, #ffffff 25px, #f2f6f6 26px) border-box;
  padding: 26px;
  overflow: hidden;
}

.document-preview.compact {
  min-height: 380px;
  margin-bottom: 14px;
}

.doc-header {
  display: flex;
  justify-content: space-between;
  padding-bottom: 16px;
  border-bottom: 2px solid #1b3035;
  font-weight: 800;
}

.doc-lines {
  display: grid;
  gap: 18px;
  margin-top: 30px;
}

.doc-lines span {
  height: 13px;
  border-radius: 999px;
  background: #dbe4e6;
}

.doc-lines span:nth-child(2) {
  width: 82%;
}

.doc-lines span:nth-child(3) {
  width: 70%;
}

.doc-lines span:nth-child(4) {
  width: 92%;
}

.template-preview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid #1b3035;
  border-bottom: 0;
  margin-top: 28px;
}

.template-preview-grid div {
  min-height: 46px;
  border-right: 1px solid #1b3035;
  border-bottom: 1px solid #1b3035;
  display: grid;
  grid-template-columns: 92px 1fr;
}

.template-preview-grid div:nth-child(2n),
.template-preview-grid .wide-cell {
  border-right: 0;
}

.template-preview-grid .wide-cell {
  grid-column: 1 / -1;
}

.template-preview-grid b {
  background: #eef3f4;
  border-right: 1px solid #1b3035;
  padding: 12px 10px;
  font-size: 12px;
}

.template-preview-grid span {
  padding: 12px 10px;
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.template-preview-grid .purpose-cell {
  min-height: 86px;
}

.signature-target {
  position: absolute;
  right: 34px;
  bottom: 42px;
  width: min(260px, 42%);
  height: 96px;
  border: 2px dashed var(--green);
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--green-dark);
  background: rgba(232, 244, 241, 0.7);
  font-weight: 800;
}

.signature-target.left {
  right: auto;
  left: 34px;
}

.phone {
  max-width: 390px;
  min-height: 640px;
  border-radius: 30px;
  background: #edf4f3;
  border: 10px solid #15292e;
  box-shadow: var(--shadow);
  padding: 18px;
}

.phone-status {
  width: 118px;
  margin: 0 auto 22px;
  border-radius: 999px;
  background: #15292e;
  color: #ffffff;
  text-align: center;
  padding: 6px;
  font-size: 12px;
}

.chat-bubble {
  max-width: 78%;
  border-radius: 8px;
  padding: 12px;
  background: #ffffff;
  box-shadow: 0 8px 18px rgba(16, 36, 41, 0.08);
}

.mini-card {
  margin-top: 14px;
  padding: 16px;
}

.mini-card h2 {
  font-size: 18px;
  line-height: 1.35;
}

.mini-card p:not(.eyebrow) {
  color: var(--muted);
  line-height: 1.5;
}

.stepper {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.step {
  border-radius: 8px;
  background: #edf2f3;
  color: var(--muted);
  padding: 10px;
  text-align: center;
  font-size: 13px;
  font-weight: 800;
}

.step.current,
.step.done {
  background: #dff3eb;
  color: var(--green-dark);
}

.verify-box {
  border: 1px solid #bcded4;
  background: #f2faf7;
  border-radius: 8px;
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.verify-box p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

#signaturePad {
  position: absolute;
  left: 26px;
  right: 26px;
  bottom: 26px;
  width: calc(100% - 52px);
  height: 150px;
  border: 2px dashed #98b7bd;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  touch-action: none;
}

#makerSignaturePad {
  width: 100%;
  height: 130px;
  border: 2px dashed #98b7bd;
  border-radius: 8px;
  background: #ffffff;
  touch-action: none;
}

.table {
  display: grid;
  gap: 10px;
}

.table-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) 120px 120px 1fr 130px;
  gap: 12px;
  align-items: center;
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fbfcfc;
}

.table-head {
  min-height: 42px;
  background: #eef3f4;
  color: var(--muted);
  font-weight: 800;
}

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

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

.archive-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
  padding: 16px;
}

.archive-item h3 {
  margin: 0 0 8px;
  font-size: 17px;
}

.archive-item p {
  margin: 5px 0;
  color: var(--muted);
}

.archive-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  max-width: min(360px, calc(100vw - 48px));
  background: #102429;
  color: #ffffff;
  border-radius: 8px;
  padding: 13px 16px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: 0.18s ease;
}

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

@media (max-width: 980px) {
  body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
    padding: 14px;
  }

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

  .nav-item {
    text-align: center;
    padding: 0 8px;
  }

  .sidebar-footer {
    display: none;
  }

  .workspace-grid,
  .phone-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .app {
    padding: 16px;
  }

  .topbar,
  .panel-title,
  .verify-box {
    flex-direction: column;
    align-items: stretch;
  }

  .dashboard-strip,
  .field-row,
  .payment-form-grid,
  .stepper {
    grid-template-columns: 1fr 1fr;
  }

  .approver-head {
    display: none;
  }

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

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

  .document-preview {
    min-height: 420px;
    padding: 18px;
  }

  .signature-target {
    width: calc(100% - 36px);
    left: 18px;
    right: auto;
  }
}
