/* ============ 全局样式 ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif; background: #f5f7fa; color: #333; line-height: 1.6; }

/* ============ 登录页 ============ */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #1a73e8, #0d47a1); }
.login-card { background: #fff; padding: 48px 40px; border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,0.15); width: 420px; max-width: 90vw; }
.login-card h1 { text-align: center; font-size: 28px; color: #1a73e8; margin-bottom: 8px; }
.login-card .subtitle { text-align: center; color: #666; margin-bottom: 32px; font-size: 14px; }
.login-card .form-group { margin-bottom: 20px; }
.login-card label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 14px; color: #555; }
.login-card input { width: 100%; padding: 12px 16px; border: 1px solid #ddd; border-radius: 8px; font-size: 15px; transition: border .2s; }
.login-card input:focus { outline: none; border-color: #1a73e8; box-shadow: 0 0 0 3px rgba(26,115,232,0.1); }
.btn { display: inline-flex; align-items: center; justify-content: center; padding: 10px 24px; border: none; border-radius: 8px; font-size: 15px; font-weight: 600; cursor: pointer; transition: all .2s; gap: 6px; }
.btn-primary { background: #1a73e8; color: #fff; width: 100%; padding: 14px; }
.btn-primary:hover { background: #1557b0; }
.btn-success { background: #0f9d58; color: #fff; }
.btn-success:hover { background: #0b7a44; }
.btn-danger { background: #ea4335; color: #fff; }
.btn-danger:hover { background: #c5221f; }
.btn-outline { background: #fff; color: #1a73e8; border: 1px solid #1a73e8; }
.btn-outline:hover { background: #e8f0fe; }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-icon { width: 36px; height: 36px; padding: 0; border-radius: 50%; }
.login-card .error { color: #ea4335; font-size: 13px; margin-top: 8px; }
.login-card .toggle-mode { text-align: center; margin-top: 20px; color: #666; font-size: 14px; }
.login-card .toggle-mode a { color: #1a73e8; cursor: pointer; text-decoration: none; font-weight: 600; }

/* ============ 管理端布局 ============ */
.admin-layout { display: flex; min-height: 100vh; }
.sidebar { width: 240px; background: #1a1f36; color: #fff; position: fixed; top: 0; left: 0; bottom: 0; overflow-y: auto; z-index: 100; display: flex; flex-direction: column; }
.sidebar .logo { padding: 24px 20px; font-size: 20px; font-weight: 700; border-bottom: 1px solid rgba(255,255,255,0.1); display: flex; align-items: center; gap: 10px; }
.sidebar .logo .icon { width: 36px; height: 36px; background: #1a73e8; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 18px; }
.sidebar-nav { flex: 1; padding: 16px 0; }
.sidebar-nav .nav-item { padding: 12px 20px; cursor: pointer; display: flex; align-items: center; gap: 10px; color: rgba(255,255,255,0.7); font-size: 15px; transition: all .2s; border-left: 3px solid transparent; }
.sidebar-nav .nav-item:hover { background: rgba(255,255,255,0.05); color: #fff; }
.sidebar-nav .nav-item.active { background: rgba(26,115,232,0.2); color: #fff; border-left-color: #1a73e8; }
.sidebar-nav .nav-item .badge { margin-left: auto; background: #ea4335; color: #fff; font-size: 11px; padding: 2px 8px; border-radius: 10px; }
.sidebar-footer { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,0.1); }
.sidebar-footer .user-info { color: rgba(255,255,255,0.7); font-size: 13px; margin-bottom: 8px; }
.sidebar-footer .logout { color: rgba(255,255,255,0.5); font-size: 13px; cursor: pointer; }
.sidebar-footer .logout:hover { color: #ea4335; }
.main-content { margin-left: 240px; flex: 1; padding: 32px; }

/* ============ 仪表盘 ============ */
.page-header { margin-bottom: 28px; }
.page-header h2 { font-size: 24px; color: #1a1f36; margin-bottom: 4px; }
.page-header .desc { color: #888; font-size: 14px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; margin-bottom: 32px; }
.stat-card { background: #fff; border-radius: 12px; padding: 24px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.stat-card .stat-label { font-size: 13px; color: #888; margin-bottom: 8px; }
.stat-card .stat-value { font-size: 32px; font-weight: 700; }
.stat-card .stat-value.blue { color: #1a73e8; }
.stat-card .stat-value.orange { color: #f9ab00; }
.stat-card .stat-value.green { color: #0f9d58; }
.stat-card .stat-value.red { color: #ea4335; }

/* ============ 表格 ============ */
.card { background: #fff; border-radius: 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.card-header { padding: 20px 24px; border-bottom: 1px solid #f0f0f0; display: flex; align-items: center; justify-content: space-between; }
.card-header h3 { font-size: 17px; color: #1a1f36; }
.card-body { padding: 0; }
.toolbar { padding: 16px 24px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.toolbar input, .toolbar select { padding: 8px 14px; border: 1px solid #ddd; border-radius: 6px; font-size: 14px; }
.toolbar input:focus, .toolbar select:focus { outline: none; border-color: #1a73e8; }
.toolbar .search-input { flex: 1; min-width: 200px; }
table { width: 100%; border-collapse: collapse; }
table th, table td { padding: 14px 24px; text-align: left; border-bottom: 1px solid #f0f0f0; }
table th { background: #fafbfc; font-size: 13px; color: #888; font-weight: 600; }
table td { font-size: 14px; }
table tbody tr:hover { background: #f8f9ff; }
.status-badge { display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; }
.status-badge.draft { background: #fff3cd; color: #856404; }
.status-badge.pending_sign { background: #cce5ff; color: #004085; }
.status-badge.signed { background: #d4edda; color: #155724; }
.status-badge.completed { background: #d1ecf1; color: #0c5460; }
.actions { display: flex; gap: 6px; }

/* ============ 弹窗/表单 ============ */
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.4); z-index: 1000; display: flex; align-items: center; justify-content: center; }
.modal { background: #fff; border-radius: 16px; max-width: 720px; width: 90vw; max-height: 85vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.2); }
.modal-header { padding: 20px 28px; border-bottom: 1px solid #f0f0f0; display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { font-size: 18px; }
.modal-close { cursor: pointer; font-size: 22px; color: #999; background: none; border: none; }
.modal-close:hover { color: #333; }
.modal-body { padding: 24px 28px; }
.modal-footer { padding: 16px 28px; border-top: 1px solid #f0f0f0; display: flex; justify-content: flex-end; gap: 10px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.form-row.single { grid-template-columns: 1fr; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 13px; color: #555; }
.form-group input, .form-group textarea, .form-group select { width: 100%; padding: 10px 14px; border: 1px solid #ddd; border-radius: 8px; font-size: 14px; font-family: inherit; }
.form-group textarea { min-height: 100px; resize: vertical; }
.form-group input:focus, .form-group textarea:focus, .form-group select:focus { outline: none; border-color: #1a73e8; box-shadow: 0 0 0 3px rgba(26,115,232,0.1); }
.form-section-title { font-size: 15px; font-weight: 700; color: #1a1f36; margin: 24px 0 12px; padding-bottom: 8px; border-bottom: 2px solid #1a73e8; }

/* ============ 合同详情 ============ */
.contract-preview { padding: 40px; max-width: 800px; margin: 0 auto; background: #fff; border-radius: 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.contract-preview .contract-title { text-align: center; font-size: 22px; font-weight: 700; margin-bottom: 32px; }
.contract-preview .contract-no { text-align: center; color: #888; font-size: 13px; margin-bottom: 24px; }
.contract-preview .party-row { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-bottom: 24px; }
.contract-preview .party-name { font-weight: 700; font-size: 16px; margin-bottom: 4px; }
.contract-preview .party-info { color: #666; font-size: 13px; }
.contract-preview .clause { margin-bottom: 16px; }
.contract-preview .clause-title { font-weight: 700; margin-bottom: 4px; }
.contract-preview .clause-content { color: #555; white-space: pre-wrap; }

/* ============ 签署页面（移动端友好） ============ */
.sign-page { min-height: 100vh; background: #f5f7fa; }
.sign-header { background: #1a73e8; color: #fff; padding: 20px 24px; text-align: center; }
.sign-header h1 { font-size: 20px; }
.sign-header .subtitle { font-size: 13px; opacity: 0.8; margin-top: 4px; }
.sign-container { max-width: 680px; margin: 0 auto; padding: 24px 16px 80px; }
.sign-contract { background: #fff; border-radius: 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); padding: 28px 24px; }
.sign-contract h2 { font-size: 18px; text-align: center; margin-bottom: 20px; }
.sign-section { margin-bottom: 24px; }
.sign-section h3 { font-size: 15px; color: #1a73e8; border-bottom: 1px solid #e0e0e0; padding-bottom: 8px; margin-bottom: 12px; }
.sign-info-row { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 14px; }
.sign-info-row .label { color: #888; }
.sign-content { background: #fafbfc; padding: 20px; border-radius: 8px; white-space: pre-wrap; font-size: 14px; color: #555; line-height: 1.8; margin-bottom: 20px; }
.sign-area { background: #fff; border: 2px dashed #ddd; border-radius: 12px; padding: 24px; text-align: center; }
.sign-area h3 { font-size: 16px; margin-bottom: 16px; color: #333; }
.sign-canvas-wrapper { position: relative; display: inline-block; border: 1px solid #ddd; border-radius: 8px; }
.sign-canvas-wrapper canvas { display: block; }
.sign-hint { font-size: 12px; color: #999; margin-top: 8px; }
.sign-actions { display: flex; gap: 10px; justify-content: center; margin-top: 16px; }
.sign-contract .btn-sign { width: 100%; padding: 16px; font-size: 17px; margin-top: 24px; }
.success-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #0f9d58, #0b7a44); }
.success-card { background: #fff; padding: 48px 40px; border-radius: 16px; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,0.15); }
.success-card .check-icon { width: 72px; height: 72px; background: #0f9d58; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin: 0 auto 20px; font-size: 36px; color: #fff; }
.success-card h2 { font-size: 24px; margin-bottom: 8px; }
.success-card p { color: #888; }

/* ============ Toast 提示 ============ */
.toast { position: fixed; top: 24px; right: 24px; z-index: 9999; padding: 14px 24px; border-radius: 8px; color: #fff; font-size: 14px; font-weight: 600; box-shadow: 0 4px 12px rgba(0,0,0,0.2); animation: slideIn 0.3s ease; max-width: 360px; }
.toast.success { background: #0f9d58; }
.toast.error { background: #ea4335; }
.toast.info { background: #1a73e8; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ============ 签署链接弹窗 ============ */
.sign-link-box { background: #f8f9ff; border: 1px solid #cce5ff; border-radius: 8px; padding: 16px; margin: 16px 0; word-break: break-all; font-size: 13px; color: #1a73e8; }
.copy-btn { padding: 8px 16px; font-size: 13px; cursor: pointer; }
.qr-placeholder { width: 160px; height: 160px; background: #f0f0f0; margin: 16px auto; display: flex; align-items: center; justify-content: center; border-radius: 8px; font-size: 13px; color: #999; }

/* ============ 管理端签名位置标注 ============ */
.admin-sign-marker {
  position: absolute;
  border: 2px dashed #e74c3c;
  background: rgba(231, 76, 60, 0.08);
  border-radius: 4px;
  cursor: move;
  display: none;
  z-index: 5;
  box-sizing: border-box;
}
.admin-sign-marker.show { display: block; }
.admin-sign-marker .resize-handle {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 18px;
  height: 18px;
  background: rgba(231, 76, 60, 0.85);
  border: 2px solid #fff;
  border-radius: 4px 0 4px 0;
  cursor: nwse-resize;
  z-index: 6;
}
.admin-sign-marker .resize-handle::after {
  content: '';
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 6px;
  height: 6px;
  border-right: 2px solid #fff;
  border-bottom: 2px solid #fff;
}
.admin-sign-select {
  position: absolute;
  border: 1px solid #1a73e8;
  background: rgba(26, 115, 232, 0.12);
  z-index: 6;
  pointer-events: none;
  box-sizing: border-box;
}
.admin-sign-marker::after {
  content: '✍ 签名位置';
  position: absolute;
  top: -24px;
  left: -2px;
  font-size: 11px;
  color: #fff;
  background: #e74c3c;
  padding: 2px 6px;
  border-radius: 3px;
  white-space: nowrap;
  font-weight: 700;
}

/* ============ 响应式 ============ */
@media (max-width: 768px) {
  .sidebar { width: 100%; position: relative; height: auto; }
  .sidebar-nav { display: flex; overflow-x: auto; padding: 8px; }
  .sidebar-nav .nav-item { border-left: none; border-bottom: 2px solid transparent; }
  .sidebar-nav .nav-item.active { border-left: none; border-bottom-color: #1a73e8; }
  .sidebar-footer { display: none; }
  .main-content { margin-left: 0; padding: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row { grid-template-columns: 1fr; }
  table { font-size: 12px; }
  table th, table td { padding: 10px 12px; }
}
