*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --primary: #1a3a5c;
  --primary-light: #2d5a8e;
  --primary-dark: #0f2440;
  --accent: #c8a96e;
  --accent-light: #e8d5a8;
  --bg: #f5f6fa;
  --card-bg: #ffffff;
  --text: #2c3e50;
  --text-light: #7f8c9b;
  --border: #e8ecf0;
  --success: #27ae60;
  --shadow: 0 2px 20px rgba(26,58,92,0.08);
  --radius: 12px;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--primary-light); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--accent); }

/* ===== Header ===== */
.header {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
  color: #fff;
  padding: 0 40px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: 1px;
}

.header-logo .icon { font-size: 1.6rem; }

.header-nav { display: flex; gap: 28px; align-items: center; }
.header-nav a { color: rgba(255,255,255,0.8); font-size: 0.9rem; font-weight: 500; }
.header-nav a:hover { color: var(--accent-light); }

/* ===== Main Content ===== */
.main { max-width: 1200px; margin: 0 auto; padding: 40px 24px; }

/* ===== Hero ===== */
.hero {
  text-align: center;
  padding: 60px 20px 50px;
  background: linear-gradient(135deg, rgba(26,58,92,0.03) 0%, rgba(200,169,110,0.08) 100%);
  border-radius: var(--radius);
  margin-bottom: 48px;
}

.hero h1 { font-size: 2.2rem; font-weight: 700; color: var(--primary); margin-bottom: 12px; }
.hero p { font-size: 1.05rem; color: var(--text-light); max-width: 560px; margin: 0 auto; }

/* ===== Contract Grid ===== */
.section-title {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.contract-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 24px;
}

.contract-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: var(--transition);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.contract-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 30px rgba(26,58,92,0.12);
  border-color: var(--accent-light);
}

.contract-card-header {
  padding: 24px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.contract-card-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.contract-card-icon.nda { background: #eef2ff; color: #4f6ef7; }
.contract-card-icon.partner { background: #fef3e7; color: #e67e22; }
.contract-card-icon.confirm { background: #e8f8ef; color: #27ae60; }

.contract-card-info { flex: 1; min-width: 0; }
.contract-card-info h3 { font-size: 1.05rem; font-weight: 600; margin-bottom: 4px; }
.contract-card-info .meta { font-size: 0.82rem; color: var(--text-light); }

.contract-card-body {
  padding: 16px 24px;
  flex: 1;
  font-size: 0.88rem;
  color: var(--text-light);
  line-height: 1.7;
}

.contract-card-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.contract-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 500;
}

.contract-status .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.contract-status .dot.pending { background: #f39c12; }
.contract-status .dot.signed { background: var(--success); }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: #fff;
}

.btn-primary:hover { background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(26,58,92,0.3); }

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}

.btn-outline:hover { background: var(--primary); color: #fff; }

.btn-accent {
  background: linear-gradient(135deg, var(--accent) 0%, #d4b87a 100%);
  color: #fff;
}

.btn-accent:hover { background: linear-gradient(135deg, #b8985a 0%, var(--accent) 100%); transform: translateY(-1px); box-shadow: 0 4px 16px rgba(200,169,110,0.4); }

.btn-success {
  background: var(--success);
  color: #fff;
}

.btn-success:hover { background: #219a52; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(39,174,96,0.3); }

.btn-lg { padding: 14px 36px; font-size: 1rem; }
.btn-sm { padding: 6px 16px; font-size: 0.82rem; }
.btn-block { width: 100%; justify-content: center; }

/* ===== Sign Page ===== */
.sign-layout {
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 32px;
  align-items: start;
}

.sign-preview {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
}

.sign-preview-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fafbfc;
}

.sign-preview-header h2 { font-size: 0.95rem; font-weight: 600; color: var(--text); }

.sign-preview-body {
  min-height: 400px;
}

/* ===== Sign Sidebar ===== */
.sign-sidebar {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.sign-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 24px;
}

.sign-card h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sign-card h3 .badge {
  font-size: 0.7rem;
  background: var(--accent);
  color: #fff;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
}

/* ===== Form ===== */
.form-group { margin-bottom: 16px; }

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}

.form-group label .required { color: #e74c3c; margin-left: 2px; }

.form-input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  transition: var(--transition);
  background: #fafbfc;
  font-family: inherit;
}

.form-input:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(45,90,142,0.1);
  background: #fff;
}

.form-input::placeholder { color: #bdc3c7; }

/* ===== Signature Pad ===== */
.signature-pad-wrapper {
  border: 1.5px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.signature-pad-wrapper.error { border-color: #e74c3c; }

.signature-pad-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: #f8f9fa;
  border-bottom: 1px solid var(--border);
}

.signature-pad-toolbar .label { font-size: 0.82rem; color: var(--text-light); }

.signature-pad-toolbar .actions { display: flex; gap: 8px; }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 0.78rem;
  color: var(--text-light);
  cursor: pointer;
  transition: var(--transition);
}

.btn-ghost:hover { background: #eef2f7; color: var(--text); }

canvas.signature-pad {
  width: 100%;
  height: 180px;
  display: block;
  cursor: crosshair;
  touch-action: none;
}

/* Type signature tab */
.signature-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.signature-tab {
  flex: 1;
  padding: 8px 16px;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  background: #f8f9fa;
  color: var(--text-light);
}

.signature-tab.active {
  background: var(--primary);
  color: #fff;
}

.signature-tab:not(.active):hover { background: #eef2f7; }

.signature-type-input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 1.6rem;
  font-family: "STKaiti", "KaiTi", "楷体", serif;
  transition: var(--transition);
  text-align: center;
  background: #fff;
}

.signature-type-input:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(45,90,142,0.1);
}

.signature-type-preview {
  display: none;
  margin-top: 12px;
}

.signature-type-preview.show { display: block; }

/* ===== Date ===== */
.sign-date {
  font-size: 0.9rem;
  color: var(--text);
  padding: 8px 0;
}

/* ===== Agreement Checkbox ===== */
.agreement { margin: 16px 0; }

.agreement label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.85rem;
  color: var(--text-light);
  cursor: pointer;
}

.agreement input[type="checkbox"] {
  margin-top: 3px;
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

/* ===== Complete Page ===== */
.complete-page {
  max-width: 600px;
  margin: 60px auto;
  text-align: center;
}

.complete-icon {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: #e8f8ef;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 24px;
  font-size: 2.4rem;
}

.complete-page h1 { font-size: 1.8rem; color: var(--primary); margin-bottom: 12px; }
.complete-page p { color: var(--text-light); margin-bottom: 8px; }

.complete-details {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 24px;
  margin: 32px 0;
  text-align: left;
}

.complete-details .row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.complete-details .row:last-child { border-bottom: none; }
.complete-details .row .label { color: var(--text-light); }
.complete-details .row .value { font-weight: 500; }

.complete-actions { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }

/* ===== Toast / Notification ===== */
.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(-80px);
  background: var(--card-bg);
  border-radius: 10px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.15);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  z-index: 999;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  border-left: 4px solid var(--primary);
}

.toast.show { transform: translateX(-50%) translateY(0); }
.toast.error { border-left-color: #e74c3c; }
.toast.success { border-left-color: var(--success); }

/* ===== Modal ===== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.modal-overlay.show { display: flex; }

.modal {
  background: var(--card-bg);
  border-radius: var(--radius);
  max-width: 520px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  animation: modalIn 0.3s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  padding: 20px 24px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 { font-size: 1.1rem; color: var(--primary); }

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: #f0f2f5;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  transition: var(--transition);
}

.modal-close:hover { background: #e0e4e9; }

.modal-body { padding: 20px 24px 24px; }

/* ===== Responsive ===== */
@media (max-width: 1024px) {
  .sign-layout { grid-template-columns: 1fr; }
  .sign-preview-body { height: 50vh; min-height: 400px; }
}

@media (max-width: 768px) {
  .header { padding: 0 20px; }
  .main { padding: 24px 16px; }
  .hero { padding: 40px 16px 30px; }
  .hero h1 { font-size: 1.6rem; }
  .contract-grid { grid-template-columns: 1fr; }
  .complete-actions { flex-direction: column; }
  .header-nav { display: none; }
}

/* ===== Print ===== */
@media print {
  .header, .sign-sidebar, .btn, .toast, .modal-overlay { display: none !important; }
  .sign-layout { display: block; }
  .sign-preview { box-shadow: none; border: 1px solid #ddd; }
  .sign-preview-body { height: auto; min-height: auto; }
}

/* ===== Loading spinner ===== */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Empty / Error States ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-light);
}

.empty-state .icon { font-size: 3rem; margin-bottom: 16px; opacity: 0.5; }
