*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f8fafc;
  color: #1e293b;
  line-height: 1.6;
}
.site-header {
  background: #fff; position: sticky; top: 0; z-index: 1000;
  border-bottom: 1px solid #e2e8f0;
}
.site-header .inner {
  max-width: 1200px; margin: 0 auto; display: flex; align-items: center;
  justify-content: space-between; padding: 0.75rem 1.5rem;
}
.site-header .logo { font-weight: 800; font-size: 1.25rem; color: #0d9488; text-decoration: none; letter-spacing: -0.02em; }
.site-header .logo span { color: #0f172a; }
.nav-link {
  padding: 6px 12px; border-radius: 6px; font-size: 0.75rem; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.05em; color: rgba(0,0,0,0.6);
  text-decoration: none; transition: all 0.15s; white-space: nowrap;
}
.nav-link:hover { color: #fff; background: #0d9488; }
.mobile-nav-link {
  display: block; padding: 12px 0; font-size: 0.875rem; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.05em; color: rgba(0,0,0,0.6);
  text-decoration: none;
}
.desktop-nav { display: none; align-items: center; gap: 0.25rem; }
@media (min-width: 640px) {
  .desktop-nav { display: flex; }
  #menu-toggle { display: none; }
  #mobile-menu { display: none; }
}
.layout { max-width: 1200px; margin: 0 auto; padding: 2rem 1.5rem; }

/* Upload zone */
.upload-zone {
  border: 2px dashed #cbd5e1; border-radius: 16px;
  padding: 3rem 2rem; text-align: center; cursor: pointer;
  transition: all 0.2s; background: #fff;
}
.upload-zone:hover, .upload-zone.dragover { border-color: #0d9488; background: #f0fdfa; }
.upload-zone h2 { font-size: 1.25rem; font-weight: 600; color: #0f172a; margin-bottom: 0.5rem; }
.upload-zone p { font-size: 0.875rem; color: #64748b; }
.upload-zone .icon { width: 3rem; height: 3rem; margin: 0 auto 1rem; color: #0d9488; }

/* Editor layout */
.editor { display: none; gap: 1.5rem; align-items: flex-start; }
.editor.active { display: flex; flex-direction: column; }
@media (min-width: 768px) {
  .editor.active { flex-direction: row; }
}
.toolbar {
  background: #fff; border-radius: 12px; border: 1px solid #e2e8f0;
  padding: 1.25rem; width: 100%; flex-shrink: 0;
}
@media (min-width: 768px) {
  .toolbar { width: 280px; }
}
.toolbar h3 { font-size: 0.8rem; font-weight: 600; color: #64748b; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 1rem; }
.tool-section { margin-bottom: 1.25rem; padding-bottom: 1.25rem; border-bottom: 1px solid #f1f5f9; }
.tool-section:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.tool-section label { display: block; font-size: 0.82rem; font-weight: 500; color: #1e293b; margin-bottom: 0.35rem; }
.tool-section .hint { font-size: 0.72rem; color: #94a3b8; margin-top: 0.25rem; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 0.55rem 1.2rem; border-radius: 8px; font-size: 0.85rem; font-weight: 600;
  border: none; cursor: pointer; transition: all 0.15s; text-decoration: none;
}
.btn-primary { background: #0d9488; color: #fff; }
.btn-primary:hover { background: #0f766e; }
.btn-secondary { background: #f1f5f9; color: #1e293b; }
.btn-secondary:hover { background: #e2e8f0; }
.btn-danger { background: #fef2f2; color: #dc2626; }
.btn-danger:hover { background: #fee2e2; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.78rem; }

/* Signature tabs */
.sig-tabs { display: flex; gap: 0; margin-bottom: 0.75rem; border: 1px solid #e2e8f0; border-radius: 8px; overflow: hidden; }
.sig-tab {
  flex: 1; padding: 0.4rem 0.75rem; font-size: 0.78rem; font-weight: 500;
  text-align: center; cursor: pointer; border: none; background: #fff; color: #64748b; transition: all 0.15s;
}
.sig-tab.active { background: #0d9488; color: #fff; }
.sig-tab:not(.active):hover { background: #f1f5f9; }

/* Preview area */
#preview-area {
  flex: 1; background: #fff; border-radius: 12px; border: 1px solid #e2e8f0;
  padding: 1.5rem; min-height: 500px; position: relative; overflow: hidden;
}
#preview-area .empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 460px; color: #94a3b8; text-align: center;
}
#preview-area .empty-state .icon { width: 4rem; height: 4rem; margin-bottom: 1rem; color: #cbd5e1; }
#preview-area .empty-state h3 { font-size: 1.1rem; font-weight: 600; color: #64748b; margin-bottom: 0.5rem; }
#pdf-container { position: relative; display: inline-block; }
#pdf-canvas { display: block; max-width: 100%; height: auto; }
.pdf-element {
  position: absolute; cursor: move; user-select: none; z-index: 10;
  border: 2px solid transparent; transition: border-color 0.15s;
}
.pdf-element:hover { border-color: #0d9488; }
.pdf-element.selected { border-color: #0d9488; background: rgba(13,148,136,0.05); }
.pdf-element .remove-btn {
  position: absolute; top: -10px; right: -10px; width: 20px; height: 20px;
  border-radius: 50%; background: #dc2626; color: #fff; border: none;
  font-size: 12px; cursor: pointer; display: none; align-items: center; justify-content: center; line-height: 1;
}
.pdf-element:hover .remove-btn { display: flex; }
.pdf-element.sig-element img { max-width: 200px; max-height: 80px; display: block; }
.pdf-element.txt-element { font-weight: 500; color: #1e293b; padding: 4px 8px; white-space: nowrap; }

/* Signature modal */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  z-index: 2000; align-items: center; justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal {
  background: #fff; border-radius: 16px; padding: 1.5rem; width: 90%; max-width: 520px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}
.modal h3 { font-size: 1.1rem; font-weight: 600; color: #0f172a; margin-bottom: 1rem; }
#sig-canvas {
  border: 2px solid #e2e8f0; border-radius: 8px; touch-action: none;
  width: 100%; height: 200px; cursor: crosshair;
}
#sig-canvas.filled { border-color: #0d9488; }
.modal-actions { display: flex; gap: 0.75rem; margin-top: 1rem; justify-content: flex-end; }

/* Text input */
#text-input {
  width: 100%; padding: 0.5rem 0.75rem; border: 1px solid #e2e8f0;
  border-radius: 8px; font-size: 0.85rem; color: #1e293b; outline: none;
  transition: border-color 0.15s;
}
#text-input:focus { border-color: #0d9488; box-shadow: 0 0 0 3px rgba(13,148,136,0.1); }
.text-options { display: flex; gap: 0.5rem; align-items: center; margin-top: 0.5rem; }
.text-options label { font-size: 0.8rem; color: #64748b; margin-bottom: 0; }
.text-options input[type="number"] {
  width: 60px; padding: 0.3rem 0.5rem; border: 1px solid #e2e8f0;
  border-radius: 6px; font-size: 0.82rem;
}
.text-options input[type="checkbox"] { accent-color: #0d9488; }

/* Footer */
.site-footer {
  background: #fff; border-top: 1px solid #e2e8f0; padding: 4rem 1.5rem 2rem;
  margin-top: 3rem;
}
.site-footer .inner { max-width: 1200px; margin: 0 auto; }
.site-footer .brand { margin-bottom: 2rem; }
.site-footer .brand .name { font-size: 1.25rem; font-weight: 700; color: #0f172a; }
.site-footer .brand .tagline { font-size: 0.8rem; color: #94a3b8; max-width: 360px; }
.site-footer .divider { border-top: 1px solid #f1f5f9; margin-bottom: 1.5rem; }
.site-footer .links { display: flex; flex-wrap: wrap; gap: 1.5rem; margin-bottom: 1.5rem; }
.site-footer .links a {
  font-size: 0.7rem; color: #94a3b8; text-decoration: none; text-transform: uppercase; letter-spacing: 0.05em;
}
.site-footer .links a:hover { color: #0d9488; }
.site-footer .copyright { font-size: 0.65rem; color: #cbd5e1; }

/* Toast */
.toast {
  position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 3000;
  background: #0f172a; color: #fff; padding: 0.75rem 1.25rem; border-radius: 10px;
  font-size: 0.85rem; font-weight: 500; display: none; box-shadow: 0 4px 24px rgba(0,0,0,0.15);
  animation: fadeInUp 0.3s ease;
}
.toast.show { display: block; }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Elements count badge */
.elements-badge {
  display: inline-flex; align-items: center; gap: 0.25rem;
  font-size: 0.75rem; color: #64748b; background: #f1f5f9;
  padding: 0.25rem 0.6rem; border-radius: 20px;
}
