/* ==========================================================================
   SignFlow — a Fellowship Automation product
   Design system: deep indigo #6366F1, Space Grotesk + Inter, light, premium.
   ========================================================================== */

:root {
  --indigo:        #6366F1;
  --indigo-600:    #4F46E5;
  --indigo-700:    #4338CA;
  --indigo-50:     #EEF0FF;
  --indigo-tint:   rgba(99, 102, 241, 0.07);
  --indigo-line:   rgba(99, 102, 241, 0.28);

  --ink:           #0F1222;
  --ink-2:         #1F2433;
  --slate:         #5B6178;
  --slate-2:       #8A90A6;
  --line:          #E7E8EE;
  --line-soft:     #EFEFF4;

  --bg:            #F6F7FB;
  --bg-grad-a:     #F4F5FB;
  --bg-grad-b:     #EDEEF8;
  --card:          #FFFFFF;
  --success:       #10B981;
  --success-50:    #E8FBF3;

  --radius:        16px;
  --radius-sm:     10px;
  --shadow-sm:     0 1px 2px rgba(16, 18, 34, 0.04), 0 1px 3px rgba(16, 18, 34, 0.06);
  --shadow-md:     0 8px 24px rgba(16, 18, 34, 0.08), 0 2px 6px rgba(16, 18, 34, 0.05);
  --shadow-lg:     0 24px 64px rgba(36, 31, 99, 0.14), 0 8px 24px rgba(16, 18, 34, 0.08);
  --shadow-indigo: 0 10px 30px rgba(99, 102, 241, 0.35);

  --font-display:  'Space Grotesk', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body:     'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(1100px 540px at 50% -10%, var(--indigo-50) 0%, rgba(238,240,255,0) 60%),
    linear-gradient(180deg, var(--bg-grad-a) 0%, var(--bg-grad-b) 100%);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.55;
}

/* ---- Brand mark ---------------------------------------------------------- */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
}
.brand-glyph {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--indigo) 0%, var(--indigo-700) 100%);
  box-shadow: var(--shadow-indigo);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.brand-glyph svg { width: 17px; height: 17px; display: block; }
.brand-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 19px;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.brand-sub {
  font-size: 11px;
  font-weight: 500;
  color: var(--slate-2);
  letter-spacing: 0.01em;
  margin-top: 1px;
}
.brand-stack { display: flex; flex-direction: column; line-height: 1.15; }

/* ---- Top bar ------------------------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 940px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.secure-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 600;
  color: var(--indigo-700);
  background: var(--indigo-tint);
  border: 1px solid var(--indigo-line);
  padding: 6px 12px;
  border-radius: 999px;
  white-space: nowrap;
}
.secure-pill svg { width: 13px; height: 13px; }

/* ---- Document intro band ------------------------------------------------- */
.intro {
  max-width: 940px;
  margin: 0 auto;
  padding: 28px 24px 8px;
}
.eyebrow {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--indigo-600);
}
.intro h1 {
  font-family: var(--font-display);
  font-size: clamp(22px, 4vw, 30px);
  font-weight: 600;
  letter-spacing: -0.025em;
  color: var(--ink);
  margin: 8px 0 6px;
}
.intro h1 .doc-name { color: var(--indigo-700); }
.intro p { color: var(--slate); font-size: 15px; max-width: 640px; }

/* ---- Step strip ---------------------------------------------------------- */
.steps {
  max-width: 940px;
  margin: 18px auto 0;
  padding: 0 24px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.step {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--slate);
}
.step-num {
  width: 22px; height: 22px;
  border-radius: 999px;
  background: var(--indigo);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
}
.step-divider { color: var(--line); align-self: center; }

/* ---- Document preview ---------------------------------------------------- */
.main {
  max-width: 940px;
  margin: 22px auto 0;
  padding: 0 24px;
}
.doc-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.doc-card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line-soft);
  background: linear-gradient(180deg, #fff 0%, #FBFBFE 100%);
}
.doc-icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: var(--indigo-tint);
  border: 1px solid var(--indigo-line);
  display: inline-flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
}
.doc-icon svg { width: 18px; height: 18px; }
.doc-meta-name { font-weight: 600; font-size: 15px; color: var(--ink); }
.doc-meta-sub { font-size: 12.5px; color: var(--slate-2); }
.doc-pages-tag {
  margin-left: auto;
  font-size: 12px;
  font-weight: 500;
  color: var(--slate);
  background: var(--bg);
  border: 1px solid var(--line);
  padding: 5px 10px;
  border-radius: 999px;
}
.doc-stage {
  padding: 22px;
  background:
    linear-gradient(180deg, #F3F4FA 0%, #ECEDF6 100%);
}
.page-container {
  position: relative;
  background: #fff;
  box-shadow: 0 4px 18px rgba(16, 18, 34, 0.10);
  border-radius: 8px;
  margin: 0 auto 18px;
  overflow: hidden;
}
.page-container:last-child { margin-bottom: 0; }
.page-container img { display: block; max-width: 100%; }

/* Signature / input field overlays */
.field-box {
  position: absolute;
  border: 1.5px dashed var(--indigo);
  background: var(--indigo-tint);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: box-shadow .15s ease, background .15s ease, border-color .15s ease;
}
.field-box input {
  width: 100%; height: 100%;
  border: none; background: transparent;
  font-size: 14px; padding: 4px 8px; outline: none;
  font-family: var(--font-body);
  color: var(--ink);
}
.field-box.signature {
  cursor: pointer;
  border-style: solid;
  border-color: var(--indigo-line);
}
.field-box.signature::after {
  content: '✎  Click to sign';
  color: var(--indigo-700);
  font-size: 12px;
  font-weight: 600;
}
.field-box.signature:hover {
  background: var(--indigo-50);
  border-color: var(--indigo);
  box-shadow: 0 0 0 4px rgba(99,102,241,0.12);
}
.field-box.signature.signed {
  border-style: solid;
  border-color: var(--success);
  background: var(--success-50);
}
.field-box.signature.signed::after { content: ''; }
.field-box.required-pulse {
  animation: pulse 1.1s ease-in-out 2;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(99,102,241,0); }
  50%      { box-shadow: 0 0 0 6px rgba(99,102,241,0.22); }
}

/* ---- Action bar ---------------------------------------------------------- */
.actionbar {
  position: sticky;
  bottom: 0;
  z-index: 30;
  margin-top: 22px;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-top: 1px solid var(--line);
}
.actionbar-inner {
  max-width: 940px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.consent {
  font-size: 12.5px;
  color: var(--slate);
  max-width: 460px;
}
.consent strong { color: var(--ink-2); font-weight: 600; }

/* ---- Electronic-signature consent (ESIGN / UETA) ------------------------- */
.consent-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  padding: 4px 0;
  border-radius: var(--radius-sm);
  transition: opacity 0.15s ease;
}
.consent-check input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.consent-box-mark {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  border: 1.6px solid var(--indigo-line);
  border-radius: 6px;
  background: var(--card);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.consent-box-mark svg {
  width: 14px;
  height: 14px;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.consent-check input:checked + .consent-box-mark {
  background: linear-gradient(135deg, var(--indigo) 0%, var(--indigo-700) 100%);
  border-color: var(--indigo-700);
}
.consent-check input:checked + .consent-box-mark svg {
  opacity: 1;
  transform: scale(1);
}
.consent-check input:focus-visible + .consent-box-mark {
  box-shadow: 0 0 0 3px var(--indigo-tint);
}
.consent-text { line-height: 1.45; }

.btn {
  font-family: var(--font-body);
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 14px 28px;
  background: linear-gradient(135deg, var(--indigo) 0%, var(--indigo-700) 100%);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 15.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  box-shadow: var(--shadow-indigo);
  transition: transform .12s ease, box-shadow .15s ease, filter .15s ease;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.04); box-shadow: 0 14px 36px rgba(99,102,241,0.42); }
.btn:active { transform: translateY(0); }
.btn:disabled { background: #C7C9D6; color: #fff; box-shadow: none; cursor: not-allowed; transform: none; filter: none; }
.btn svg { width: 17px; height: 17px; }

/* ---- Modal --------------------------------------------------------------- */
.modal {
  display: none;
  position: fixed; inset: 0;
  background: rgba(15, 18, 34, 0.55);
  backdrop-filter: blur(4px);
  z-index: 100;
  align-items: center; justify-content: center;
  padding: 20px;
}
.modal.active { display: flex; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal-content {
  background: #fff;
  border-radius: 20px;
  padding: 28px;
  width: 440px; max-width: 100%;
  box-shadow: var(--shadow-lg);
  animation: pop .2s cubic-bezier(.2,.8,.2,1);
}
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-content h3 {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}
.modal-content .modal-hint { font-size: 13px; color: var(--slate); margin-bottom: 18px; }
.sig-input {
  width: 100%;
  padding: 14px 16px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  font-size: 16px;
  font-family: var(--font-body);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
  margin-bottom: 14px;
}
.sig-input:focus { border-color: var(--indigo); box-shadow: 0 0 0 4px rgba(99,102,241,0.14); }
.sig-preview-label { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--slate-2); margin-bottom: 7px; }
.sig-preview {
  font-family: 'Brush Script MT', 'Segoe Script', cursive;
  font-size: 34px;
  color: var(--ink);
  text-align: center;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 20px;
  min-height: 76px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, #fff 0%, #FBFBFE 100%);
}
.sig-preview.empty { color: var(--slate-2); font-family: var(--font-body); font-size: 14px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }
.btn-cancel {
  padding: 12px 20px;
  background: #fff;
  color: var(--ink-2);
  border: 1.5px solid var(--line);
  border-radius: 11px;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.btn-cancel:hover { background: var(--bg); border-color: #D7D8E0; }
.modal-actions .btn { padding: 12px 22px; font-size: 14.5px; }

/* ---- Success state ------------------------------------------------------- */
.success-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.success-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow-lg);
  padding: 48px 40px 36px;
  max-width: 460px;
  width: 100%;
  text-align: center;
}
.success-badge {
  width: 76px; height: 76px;
  margin: 0 auto 22px;
  border-radius: 50%;
  background: var(--success-50);
  border: 1px solid rgba(16,185,129,0.25);
  display: flex; align-items: center; justify-content: center;
  animation: pop .35s cubic-bezier(.2,.8,.2,1);
}
.success-badge svg { width: 38px; height: 38px; }
.success-card h2 {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.025em;
  margin-bottom: 8px;
}
.success-card p { color: var(--slate); font-size: 15px; }
.success-card .doc-ref {
  margin-top: 18px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
  background: var(--bg);
  border: 1px solid var(--line);
  padding: 8px 14px;
  border-radius: 10px;
}
.success-meta { margin-top: 22px; font-size: 12.5px; color: var(--slate-2); }

/* ---- Footer -------------------------------------------------------------- */
.footer {
  max-width: 940px;
  margin: 30px auto 0;
  padding: 22px 24px 40px;
  text-align: center;
  border-top: 1px solid var(--line-soft);
}
.footer .brand { justify-content: center; }
.footer-tag {
  margin-top: 12px;
  font-size: 12.5px;
  color: var(--slate-2);
}
.footer-tag strong { color: var(--slate); font-weight: 600; }
.footer-legal {
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--slate-2);
}

/* ---- Responsive ---------------------------------------------------------- */
@media (max-width: 640px) {
  .topbar-inner, .intro, .steps, .main, .actionbar-inner, .footer { padding-left: 16px; padding-right: 16px; }
  .secure-pill span { display: none; }
  .secure-pill { padding: 6px 9px; }
  .doc-stage { padding: 12px; }
  .actionbar-inner { flex-direction: column; align-items: stretch; }
  .actionbar-inner .btn { width: 100%; justify-content: center; }
  .consent { max-width: none; text-align: center; }
  .steps { gap: 6px; }
  .step span { display: none; }
  .intro h1 { font-size: 22px; }
}
