:root {
  --bg: #f3f6fb;
  --panel: #ffffff;
  --panel-alt: #edf3ff;
  --primary: #2149d8;
  --primary-strong: #1a3bb6;
  --accent: #eef7ff;
  --line: #dfe6f5;
  --text: #1d2433;
  --muted: #67738a;
  --success: #1b9c5d;
  --danger: #d94d5b;
  --shadow: 0 18px 45px rgba(19, 34, 82, 0.12);
  --radius: 22px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #edf3ff 0%, #f8faff 50%, #eef8f4 100%);
  color: var(--text);
}

body {
  min-height: 100vh;
}

button,
input {
  font: inherit;
}

button {
  border: none;
  cursor: pointer;
}

.app-shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 20px 40px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 18px;
  padding: 14px 18px;
  box-shadow: 0 10px 28px rgba(24, 41, 75, 0.06);
  margin-bottom: 20px;
}

.brand {
  font-weight: 700;
  letter-spacing: 0.02em;
  font-size: 1.15rem;
  white-space: nowrap;
}

.lang-switch {
  display: flex;
  gap: 8px;
  background: var(--panel-alt);
  border-radius: 12px;
  padding: 6px;
}

.lang-btn {
  padding: 8px 12px;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
}

.lang-btn.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 8px 20px rgba(33, 73, 216, 0.28);
}

.page-stack {
  position: relative;
}

.page {
  display: none;
  width: 100%;
  min-height: 70vh;
}

.page.active {
  display: block;
}

.hero-card {
  max-width: 860px;
  margin: 0 auto;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(218, 226, 244, 0.8);
  border-radius: 30px;
  padding: 54px 36px 42px;
  box-shadow: var(--shadow);
  text-align: center;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--primary);
  margin: 0 0 18px;
}

.hero-card h1 {
  font-size: clamp(2.3rem, 4vw, 4rem);
  line-height: 1.06;
  margin: 0 0 18px;
  white-space: nowrap;
}

.lead {
  max-width: 620px;
  margin: 0 auto 30px;
  color: var(--muted);
  font-size: 1.06rem;
  line-height: 1.6;
}

.actions-row,
.final-actions,
.sign-tools {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 14px;
}

.actions-row {
  flex-direction: column;
  align-items: center;
}

.actions-row > * {
  width: min(100%, 320px);
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.share-option {
  padding: 14px 22px;
  border-radius: 14px;
  font-weight: 700;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.primary-btn:hover,
.secondary-btn:hover,
.ghost-btn:hover,
.share-option:hover {
  transform: translateY(-1px);
}

.primary-btn {
  background: linear-gradient(135deg, var(--primary), #3a68ff);
  color: #fff;
  box-shadow: 0 15px 30px rgba(33, 73, 216, 0.25);
}

.secondary-btn {
  background: #edf3ff;
  color: var(--primary);
}

.ghost-btn {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.section-header h2 {
  margin: 0;
  font-size: clamp(1.7rem, 2vw, 2.5rem);
}

.sticky-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(243, 246, 251, 0.92);
  backdrop-filter: blur(10px);
  padding: 12px 0 18px;
  border-bottom: 1px solid rgba(223, 230, 245, 0.9);
}

.upload-panel {
  max-width: 980px;
  margin: 18px auto 0;
}

.dropzone {
  display: block;
  background: rgba(255, 255, 255, 0.8);
  border: 2px dashed #bfd0ff;
  border-radius: 26px;
  min-height: 350px;
  width: 100%;
  position: relative;
  box-shadow: var(--shadow);
  transition: border-color 0.2s ease, transform 0.2s ease;
  cursor: pointer;
}

.dropzone.dragover {
  border-color: var(--primary);
  transform: scale(1.01);
}

.dropzone input {
  position: fixed;
  width: 1px;
  height: 1px;
  left: -9999px;
  top: -9999px;
  opacity: 0;
  pointer-events: none;
}

.dropzone-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-height: 350px;
  text-align: center;
  padding: 20px;
  color: var(--muted);
}

.upload-icon {
  width: 82px;
  height: 82px;
  display: grid;
  place-items: center;
  font-size: 2.3rem;
  background: linear-gradient(135deg, rgba(33, 73, 216, 0.12), rgba(33, 73, 216, 0.04));
  color: var(--primary);
  border-radius: 50%;
}

.doc-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
  margin-top: 10px;
}

.doc-card {
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 16px;
  box-shadow: 0 14px 36px rgba(27, 39, 68, 0.06);
}

.doc-card h3 {
  margin: 0 0 6px;
  font-size: 1.12rem;
}

.doc-meta {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 14px;
}

.doc-card-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.doc-card-actions button {
  padding: 10px 12px;
  border-radius: 10px;
  font-weight: 600;
}

.doc-card-actions .mini-btn {
  background: #edf3ff;
  color: var(--primary);
}

.doc-card-actions .share-mini-btn {
  background: #eaf8f1;
  color: var(--success);
}

.doc-card-actions .delete-btn {
  background: #fff0f2;
  color: var(--danger);
}

.doc-share-options {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.sign-document-area {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 20px;
  align-items: start;
}

.signing-toolbar,
.signature-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.signature-editor {
  margin-top: 20px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 18px;
  box-shadow: 0 10px 30px rgba(17, 38, 80, 0.08);
}

.signature-pad-shell {
  background: #f4f7ff;
  border: 2px solid rgba(11, 45, 107, 0.2);
  border-radius: 18px;
  overflow: hidden;
}

#signature-pad {
  display: block;
  width: 100%;
  height: 200px;
  cursor: crosshair;
  background: #f4f7ff;
}

.page-list-wrap {
  margin-top: 22px;
}

.page-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.page-chip {
  min-width: 44px;
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: white;
  color: var(--text);
  font-weight: 700;
}

.page-chip.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.page-surface {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 10px 28px rgba(15, 29, 58, 0.08);
  padding: 14px;
}

.page-surface h4 {
  margin: 0 0 12px;
  font-size: 0.95rem;
  color: var(--muted);
}

.page-canvas-wrap {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  background: linear-gradient(135deg, #f3f6fb, #edf6f3);
  border: 1px solid #dfe7ff;
}

.page-canvas-wrap canvas {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.page-canvas-wrap canvas:active {
  cursor: grabbing;
}

.page-nav-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-indicator-wrap {
  font-weight: 700;
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--muted);
}

.page-indicator-wrap #page-indicator {
  color: var(--text);
}

.final-preview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
  margin: 14px 0 28px;
}

.final-page-card {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 10px 24px rgba(23, 40, 73, 0.08);
}

.final-page-card canvas {
  display: block;
  width: 100%;
  height: auto;
}

.share-options {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.share-option {
  background: #eef6ff;
  color: var(--primary);
}

.share-option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.share-option[data-share="email"],
.share-option[data-platform="email"] {
  background: #ea4335;
  color: #fff;
}

.share-option[data-share="telegram"],
.share-option[data-platform="telegram"] {
  background: #229ed9;
  color: #fff;
}

.share-option[data-share="whatsapp"],
.share-option[data-platform="whatsapp"] {
  background: #25d366;
  color: #fff;
}

.hidden {
  display: none !important;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 24px;
  background: rgba(22, 31, 45, 0.95);
  color: white;
  padding: 12px 16px;
  border-radius: 12px;
  box-shadow: 0 18px 35px rgba(15, 23, 42, 0.25);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.empty-state {
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 28px 20px;
  text-align: center;
  color: var(--muted);
}

@media (max-width: 720px) {
  .app-shell {
    padding-inline: 14px;
  }

  .hero-card {
    padding: 28px 18px 26px;
  }

  .hero-card h1 {
    font-size: 0.95rem;
  }

  .section-header {
    flex-wrap: wrap;
  }

  .actions-row,
  .final-actions {
    flex-direction: column;
  }

  .primary-btn,
  .secondary-btn,
  .ghost-btn {
    width: 100%;
  }
}
