/* ==========================================================================
   JDdox Signing -- design system
   A DocuSign-inspired visual language: deep navy chrome, a warm gold
   call-to-action accent, crisp white document surfaces, and colour-coded
   "tag" affordances for each field type.
   ========================================================================== */

@font-face {
  font-family: 'Caveat';
  src: url('../vendor/fonts/caveat.woff2') format('woff2');
  font-weight: 500 700;
  font-display: swap;
}
@font-face {
  font-family: 'Dancing Script';
  src: url('../vendor/fonts/dancing-script.woff2') format('woff2');
  font-weight: 600 700;
  font-display: swap;
}

:root {
  --ink-950: #070b16;
  --ink-900: #0b1220;
  --ink-800: #121b31;
  --ink-700: #1b2540;
  --ink-600: #2a3556;

  --gold: #ffc72c;
  --gold-dark: #e8a900;
  --gold-ink: #4d3600;

  --blue: #2f6fed;
  --blue-soft: #eaf1ff;
  --purple: #7b3fe4;
  --purple-soft: #f3edfe;
  --teal: #0f9d8c;
  --teal-soft: #e6f8f5;
  --green: #1f9d63;
  --green-soft: #e8f8ef;
  --red: #d6455a;
  --red-soft: #fdecee;
  --amber: #c98a02;
  --amber-soft: #fff6e0;

  --surface: #ffffff;
  --surface-alt: #f5f6f9;
  --surface-sunk: #eef0f4;
  --border: #e2e5ec;
  --border-strong: #cbd0db;

  --text-primary: #171d2e;
  --text-secondary: #5b6472;
  --text-tertiary: #8891a0;
  --text-on-dark: #eef1f8;
  --text-on-dark-soft: #a9b3c9;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 1px rgba(15, 23, 42, .04);
  --shadow-md: 0 6px 16px rgba(15, 23, 42, .10), 0 2px 6px rgba(15, 23, 42, .06);
  --shadow-lg: 0 20px 45px rgba(9, 14, 30, .22), 0 6px 18px rgba(9, 14, 30, .12);
  --shadow-gold: 0 10px 26px rgba(232, 169, 0, .35);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-pill: 999px;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-signature: 'Caveat', cursive;
  --font-signature-alt: 'Dancing Script', cursive;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--text-primary);
  background: var(--surface-alt);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
p { margin: 0; }
a { color: inherit; }
button { font-family: inherit; }
::selection { background: rgba(255, 199, 44, .35); }

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: .6rem 1.1rem;
  font-size: .92rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, background-color .15s ease, border-color .15s ease, opacity .15s ease;
  text-decoration: none;
  line-height: 1.1;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.btn--gold {
  background: linear-gradient(180deg, #ffd45c, var(--gold));
  color: #241a00;
  box-shadow: var(--shadow-gold);
}
.btn--gold:hover:not(:disabled) { box-shadow: 0 12px 30px rgba(232, 169, 0, .45); }

.btn--dark {
  background: var(--ink-900);
  color: var(--text-on-dark);
}
.btn--dark:hover:not(:disabled) { background: var(--ink-800); }

.btn--outline {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text-primary);
}
.btn--outline:hover:not(:disabled) { border-color: var(--ink-700); background: var(--surface-alt); }

.btn--ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn--ghost:hover:not(:disabled) { background: var(--surface-sunk); color: var(--text-primary); }

.btn--danger { background: var(--red-soft); color: var(--red); }
.btn--danger:hover:not(:disabled) { background: #f9d9dd; }

.btn--sm { padding: .4rem .75rem; font-size: .82rem; border-radius: 7px; }
.btn--icon { width: 34px; height: 34px; padding: 0; border-radius: var(--radius-pill); }
.btn--block { width: 100%; }

/* --------------------------------------------------------------------------
   Badges / pills
   -------------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .2rem .6rem;
  border-radius: var(--radius-pill);
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.badge--sent { background: var(--blue-soft); color: var(--blue); }
.badge--viewed { background: var(--amber-soft); color: var(--amber); }
.badge--completed { background: var(--green-soft); color: var(--green); }
.badge--voided { background: var(--surface-sunk); color: var(--text-tertiary); }
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* --------------------------------------------------------------------------
   Flash messages
   -------------------------------------------------------------------------- */
.flash-stack {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 900;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 380px;
}
.flash {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .75rem;
  background: var(--ink-900);
  color: var(--text-on-dark);
  padding: .8rem 1rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: .88rem;
  animation: flashIn .25s ease;
}
.flash--error { background: #4a1620; }
.flash--success { background: #103826; }
.flash--fade { opacity: 0; transform: translateX(8px); transition: opacity .4s ease, transform .4s ease; }
.flash__dismiss {
  background: none; border: none; color: inherit; opacity: .6; cursor: pointer;
  font-size: 1.1rem; line-height: 1; padding: 0 0 0 .5rem;
}
.flash__dismiss:hover { opacity: 1; }
@keyframes flashIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }

/* --------------------------------------------------------------------------
   Auth / login
   -------------------------------------------------------------------------- */
.auth-page {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1200px 800px at 15% -10%, #1c2947 0%, transparent 60%),
    radial-gradient(900px 700px at 110% 10%, #26345c 0%, transparent 55%),
    linear-gradient(180deg, var(--ink-950), var(--ink-900));
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 2.2rem 2rem 1.8rem;
  animation: cardIn .45s cubic-bezier(.2, .8, .25, 1);
}
@keyframes cardIn { from { opacity: 0; transform: translateY(14px) scale(.985); } to { opacity: 1; transform: none; } }
.auth-mark {
  display: flex; align-items: center; gap: .6rem; margin-bottom: 1.4rem;
}
.auth-mark__badge {
  width: 40px; height: 40px; border-radius: 11px;
  background: var(--ink-900);
  display: flex; align-items: center; justify-content: center;
}
.auth-mark__badge svg { width: 22px; height: 22px; }
.auth-mark__text { font-size: 1.15rem; font-weight: 800; letter-spacing: -.01em; }
.auth-mark__text span { color: var(--gold-dark); }
.auth-card h1 { font-size: 1.3rem; margin-bottom: .3rem; }
.auth-card .sub { color: var(--text-secondary); font-size: .9rem; margin-bottom: 1.5rem; }
.field-group { margin-bottom: 1.1rem; }
.field-group label {
  display: block; font-size: .78rem; font-weight: 700; color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: .04em; margin-bottom: .4rem;
}
.text-input, .textarea-input {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .65rem .8rem;
  font-size: .95rem;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--surface);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.text-input:focus, .textarea-input:focus {
  outline: none; border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(47, 111, 237, .15);
}
.auth-hint { margin-top: 1.2rem; font-size: .78rem; color: var(--text-tertiary); text-align: center; }

/* --------------------------------------------------------------------------
   Dashboard
   -------------------------------------------------------------------------- */
.topbar {
  background: var(--ink-900);
  color: var(--text-on-dark);
  padding: 0 1.5rem;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky; top: 0; z-index: 40;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .18);
}
.topbar__brand { display: flex; align-items: center; gap: .6rem; font-weight: 800; }
.topbar__brand .auth-mark__badge { width: 32px; height: 32px; border-radius: 9px; background: rgba(255, 255, 255, .08); }
.topbar__brand .auth-mark__badge svg { width: 18px; height: 18px; }
.topbar__actions { display: flex; align-items: center; gap: .6rem; }

.shell { max-width: 1080px; margin: 0 auto; padding: 2.2rem 1.5rem 4rem; }
.shell-header { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 1.4rem; flex-wrap: wrap; gap: .6rem; }
.shell-header h1 { font-size: 1.5rem; }
.shell-header .sub { color: var(--text-secondary); font-size: .92rem; }

.doc-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  margin-bottom: 1.4rem;
  overflow: hidden;
}
.doc-card__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.2rem 1.4rem; gap: 1rem; flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
}
.doc-card__title { display: flex; align-items: center; gap: .9rem; }
.doc-card__icon {
  width: 44px; height: 56px; border-radius: 6px;
  background: var(--surface-sunk); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  position: relative;
}
.doc-card__icon::before {
  content: ''; position: absolute; inset: 8px 8px auto 8px; height: 2px; background: var(--border-strong);
  box-shadow: 0 6px 0 var(--border-strong), 0 12px 0 var(--border-strong), 0 18px 0 var(--border-strong);
}
.doc-card__title h2 { font-size: 1.08rem; }
.doc-card__meta { font-size: .82rem; color: var(--text-tertiary); margin-top: .15rem; }
.doc-card__stats { display: flex; gap: .5rem; flex-wrap: wrap; }
.stat-chip {
  background: var(--surface-alt); border: 1px solid var(--border);
  border-radius: var(--radius-pill); padding: .3rem .7rem;
  font-size: .78rem; color: var(--text-secondary); font-weight: 600;
}
.stat-chip b { color: var(--text-primary); }
.doc-card__actions { display: flex; gap: .5rem; }

.new-link-form {
  display: none;
  padding: 1.1rem 1.4rem;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
  gap: .8rem;
  flex-wrap: wrap;
  align-items: end;
}
.new-link-form.is-open { display: flex; }
.new-link-form .field-group { margin-bottom: 0; flex: 1 1 160px; }
.new-link-form .field-group.grow { flex: 2 1 220px; }

.env-table { width: 100%; border-collapse: collapse; }
.env-table th {
  text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-tertiary); font-weight: 700; padding: .7rem 1.4rem; border-bottom: 1px solid var(--border);
}
.env-table td { padding: .8rem 1.4rem; border-bottom: 1px solid var(--border); font-size: .88rem; vertical-align: middle; }
.env-table tr:last-child td { border-bottom: none; }
.env-table .signer-name { font-weight: 700; }
.env-table .signer-email { color: var(--text-tertiary); font-size: .78rem; }
.env-table .row-actions { display: flex; gap: .4rem; justify-content: flex-end; }
.empty-row td { color: var(--text-tertiary); font-style: italic; text-align: center; padding: 1.6rem; }

.link-copy-box {
  display: flex; align-items: center; gap: .5rem;
  background: var(--surface-sunk); border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm); padding: .55rem .7rem; margin-top: .8rem;
  font-size: .8rem; color: var(--text-secondary); word-break: break-all;
}

/* --------------------------------------------------------------------------
   Modals (shared)
   -------------------------------------------------------------------------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(7, 11, 22, .55);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 20px; backdrop-filter: blur(2px);
  animation: fadeIn .18s ease;
}
.modal-backdrop.is-hidden { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); width: 100%; max-width: 460px;
  max-height: 90vh; overflow: auto;
  animation: modalIn .22s cubic-bezier(.2, .8, .25, 1);
}
.modal--wide { max-width: 620px; }
@keyframes modalIn { from { opacity: 0; transform: translateY(16px) scale(.97); } to { opacity: 1; transform: none; } }
.modal__head { padding: 1.3rem 1.4rem .6rem; display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.modal__head h2 { font-size: 1.15rem; }
.modal__head p { color: var(--text-secondary); font-size: .86rem; margin-top: .3rem; }
.modal__close { background: none; border: none; color: var(--text-tertiary); font-size: 1.3rem; cursor: pointer; line-height: 1; }
.modal__body { padding: .6rem 1.4rem 1.2rem; }
.modal__foot { padding: 1rem 1.4rem 1.4rem; display: flex; justify-content: flex-end; gap: .6rem; }

/* --------------------------------------------------------------------------
   Prepare (field tagging) workspace
   -------------------------------------------------------------------------- */
.prep-shell { display: flex; flex-direction: column; height: 100vh; background: var(--surface-sunk); }
.prep-topbar {
  height: 58px; background: var(--ink-900); color: var(--text-on-dark);
  display: flex; align-items: center; justify-content: space-between; padding: 0 1.2rem;
  flex-shrink: 0; z-index: 50; box-shadow: 0 2px 10px rgba(0, 0, 0, .18);
}
.prep-topbar__title { display: flex; align-items: center; gap: .7rem; font-weight: 700; font-size: .95rem; }
.prep-topbar__title .doc-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--gold); }
.prep-topbar__status { font-size: .78rem; color: var(--text-on-dark-soft); }
.prep-topbar__status.is-dirty { color: var(--gold); font-weight: 700; }
.prep-body { flex: 1; display: flex; min-height: 0; }

.prep-palette {
  width: 232px; flex-shrink: 0; background: var(--ink-800); color: var(--text-on-dark);
  padding: 1.1rem .9rem; overflow-y: auto;
}
.prep-palette h3 { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-on-dark-soft); margin-bottom: .7rem; }
.palette-chip {
  display: flex; align-items: center; gap: .6rem;
  padding: .65rem .7rem; border-radius: var(--radius-sm); margin-bottom: .5rem;
  cursor: grab; border: 1.5px solid transparent; background: rgba(255, 255, 255, .04);
  font-size: .86rem; font-weight: 600; transition: background .15s ease, border-color .15s ease;
  user-select: none;
}
.palette-chip:hover { background: rgba(255, 255, 255, .09); }
.palette-chip.is-active { border-color: var(--gold); background: rgba(255, 199, 44, .12); }
.palette-chip__swatch { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; }
.palette-hint { font-size: .76rem; color: var(--text-on-dark-soft); line-height: 1.5; margin-top: 1.2rem; padding-top: 1.1rem; border-top: 1px solid rgba(255, 255, 255, .08); }
.palette-count { margin-left: auto; font-size: .72rem; color: var(--text-on-dark-soft); background: rgba(255, 255, 255, .08); padding: .05rem .4rem; border-radius: var(--radius-pill); }

.prep-canvas-scroll { flex: 1; overflow: auto; padding: 2rem 0 6rem; }
.pdf-pages { display: flex; flex-direction: column; align-items: center; gap: 22px; }
.pdf-page {
  position: relative; background: #fff; box-shadow: var(--shadow-md); line-height: 0;
}
.pdf-page canvas { display: block; }
.pdf-page__number {
  position: absolute; bottom: -26px; left: 50%; transform: translateX(-50%);
  font-size: .72rem; color: var(--text-tertiary); font-weight: 600;
}
.pdf-page.is-dropzone { outline: 2px dashed var(--gold); outline-offset: 4px; }

.field-box {
  position: absolute; border-radius: 5px; cursor: move;
  display: flex; align-items: center; justify-content: center;
  font-size: .72rem; font-weight: 700; color: #fff;
  border: 1.5px solid transparent;
}
.field-box[data-type="signature"] { background: rgba(255, 199, 44, .28); border-color: var(--gold-dark); }
.field-box[data-type="initials"] { background: rgba(123, 63, 228, .22); border-color: var(--purple); }
.field-box[data-type="date"] { background: rgba(47, 111, 237, .18); border-color: var(--blue); }
.field-box[data-type="full_name"] { background: rgba(15, 157, 140, .18); border-color: var(--teal); }
.field-box[data-type="text"] { background: rgba(91, 100, 114, .16); border-color: var(--text-secondary); }
.field-box__label {
  position: absolute; top: -22px; left: -1.5px; white-space: nowrap;
  padding: .1rem .4rem; border-radius: 5px 5px 5px 0; font-size: .66rem;
  background: inherit; filter: brightness(0.55); color: #fff;
}
.field-box .field-box__label { background: var(--ink-900); filter: none; }
.field-box__required { position: absolute; top: -8px; right: -8px; }
.field-box__required input { accent-color: var(--gold-dark); cursor: pointer; }
.field-box__delete {
  position: absolute; top: -22px; right: -1.5px; width: 18px; height: 18px;
  border-radius: 4px; background: var(--red); color: #fff; border: none;
  font-size: .72rem; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.field-box__resize {
  position: absolute; right: -4px; bottom: -4px; width: 12px; height: 12px;
  background: #fff; border: 1.5px solid var(--ink-700); border-radius: 3px; cursor: nwse-resize;
}
.field-box.is-selected { box-shadow: 0 0 0 3px rgba(255, 255, 255, .5), var(--shadow-md); z-index: 5; }

.prep-empty-hint {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: var(--ink-900); color: var(--text-on-dark); padding: .7rem 1.1rem;
  border-radius: var(--radius-pill); font-size: .82rem; box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: .5rem; z-index: 30;
}
.prep-empty-hint kbd { background: rgba(255, 255, 255, .12); padding: .1rem .4rem; border-radius: 4px; font-size: .74rem; }

/* --------------------------------------------------------------------------
   Signing experience
   -------------------------------------------------------------------------- */
.sign-shell { display: flex; flex-direction: column; height: 100vh; background: var(--surface-sunk); }
.sign-topbar {
  background: var(--ink-900); color: var(--text-on-dark);
  padding: 0 1.2rem; height: 62px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .18); z-index: 60;
}
.sign-topbar__left { display: flex; align-items: center; gap: .8rem; min-width: 0; }
.sign-topbar__doc { font-weight: 700; font-size: .92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sign-topbar__signer { font-size: .74rem; color: var(--text-on-dark-soft); }
.sign-progress-wrap { flex: 1; max-width: 320px; display: flex; align-items: center; gap: .7rem; }
.sign-progress-track { flex: 1; height: 7px; border-radius: 4px; background: rgba(255, 255, 255, .14); overflow: hidden; }
.sign-progress-bar { height: 100%; background: linear-gradient(90deg, var(--gold-dark), var(--gold)); width: 0%; transition: width .35s ease; border-radius: 4px; }
.sign-progress-label { font-size: .78rem; color: var(--text-on-dark-soft); white-space: nowrap; font-variant-numeric: tabular-nums; }

.sign-canvas-scroll { flex: 1; overflow: auto; padding: 2rem 0 8rem; scroll-behavior: smooth; }

.field-tag {
  position: absolute; border-radius: 6px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: .3rem;
  border: 2px solid; font-weight: 700; overflow: visible;
  transition: transform .12s ease, box-shadow .12s ease;
  background: rgba(255, 255, 255, .55);
}
.field-tag:hover { transform: translateY(-1px); }
.field-tag[data-type="signature"] { border-color: var(--gold-dark); background: rgba(255, 199, 44, .22); }
.field-tag[data-type="initials"] { border-color: var(--purple); background: rgba(123, 63, 228, .16); }
.field-tag[data-type="date"] { border-color: var(--blue); background: rgba(47, 111, 237, .14); }
.field-tag[data-type="full_name"] { border-color: var(--teal); background: rgba(15, 157, 140, .14); }
.field-tag[data-type="text"] { border-color: var(--text-secondary); background: rgba(91, 100, 114, .12); }
.field-tag__chip {
  position: absolute; top: -13px; left: -2px;
  padding: .12rem .45rem; border-radius: 5px 5px 5px 0;
  font-size: .66rem; letter-spacing: .02em; color: #fff; white-space: nowrap;
  display: flex; align-items: center; gap: .25rem;
}
.field-tag[data-type="signature"] .field-tag__chip { background: var(--gold-dark); color: #241a00; }
.field-tag[data-type="initials"] .field-tag__chip { background: var(--purple); }
.field-tag[data-type="date"] .field-tag__chip { background: var(--blue); }
.field-tag[data-type="full_name"] .field-tag__chip { background: var(--teal); }
.field-tag[data-type="text"] .field-tag__chip { background: var(--text-secondary); }

.field-tag.is-required::after {
  content: ''; position: absolute; inset: -2px; border-radius: 8px;
  box-shadow: 0 0 0 0 rgba(255, 199, 44, .55);
  animation: tagPulse 2.2s ease-in-out infinite;
  pointer-events: none;
}
.field-tag.is-focused::after { animation-duration: 1s; }
@keyframes tagPulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 199, 44, .5); }
  70% { box-shadow: 0 0 0 8px rgba(255, 199, 44, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 199, 44, 0); }
}
.field-tag.is-done {
  cursor: default; background: #fff; border-style: solid;
  animation: none;
}
.field-tag.is-done::after { display: none; }
.field-tag.is-done .field-tag__chip { display: none; }
.field-tag__check {
  position: absolute; top: -9px; right: -9px; width: 19px; height: 19px; border-radius: 50%;
  background: var(--green); color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: .68rem; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); opacity: 0; transform: scale(.4);
  transition: opacity .18s ease, transform .18s ease;
}
.field-tag.is-done .field-tag__check { opacity: 1; transform: scale(1); }
.field-tag__stamp-img { max-width: 100%; max-height: 100%; object-fit: contain; }
.field-tag__stamp-text { font-family: var(--font-sans); font-weight: 600; color: var(--text-primary); font-size: .8em; padding: 0 4px; }
.field-tag[data-type="signature"] .field-tag__stamp-img,
.field-tag[data-type="initials"] .field-tag__stamp-img { filter: none; }

.sign-floating-next {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  z-index: 55; display: flex; align-items: center; gap: .6rem;
  background: var(--ink-900); color: #fff; padding: .65rem .7rem .65rem 1.1rem;
  border-radius: var(--radius-pill); box-shadow: var(--shadow-lg);
  font-size: .86rem; font-weight: 600; transition: opacity .2s ease, transform .2s ease;
}
.sign-floating-next.is-hidden { opacity: 0; pointer-events: none; transform: translate(-50%, 12px); }
.sign-floating-next .btn { background: var(--gold); color: #241a00; }

/* Consent + adopt modals */
.consent-icon, .success-icon {
  width: 52px; height: 52px; border-radius: 14px; background: var(--ink-900);
  display: flex; align-items: center; justify-content: center; margin-bottom: 1rem;
}
.consent-check { display: flex; align-items: flex-start; gap: .6rem; background: var(--surface-alt); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .8rem .9rem; margin-top: .6rem; }
.consent-check input { margin-top: .2rem; accent-color: var(--gold-dark); width: 16px; height: 16px; flex-shrink: 0; }
.consent-check label { font-size: .84rem; color: var(--text-secondary); line-height: 1.45; }

.adopt-tabs { display: flex; gap: .4rem; margin-bottom: 1rem; background: var(--surface-sunk); padding: .25rem; border-radius: var(--radius-sm); }
.adopt-tab { flex: 1; text-align: center; padding: .5rem; border-radius: 7px; font-size: .84rem; font-weight: 700; cursor: pointer; color: var(--text-secondary); }
.adopt-tab.is-active { background: var(--surface); color: var(--text-primary); box-shadow: var(--shadow-sm); }
.adopt-pane { display: none; }
.adopt-pane.is-active { display: block; }
.adopt-row { display: flex; gap: .8rem; }
.adopt-row .field-group { flex: 1; }
.style-picker { display: flex; gap: .5rem; margin-bottom: 1rem; }
.style-swatch {
  flex: 1; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  padding: .5rem; cursor: pointer; text-align: center; font-size: 1.3rem; background: var(--surface);
}
.style-swatch.is-active { border-color: var(--gold-dark); box-shadow: 0 0 0 3px rgba(255, 199, 44, .18); }
.sig-preview {
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface-alt); padding: .8rem 1rem; margin-top: .3rem;
  display: flex; flex-direction: column; gap: .3rem;
}
.sig-preview__label { font-size: .68rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-tertiary); font-weight: 700; }
.sig-preview__text { font-family: var(--font-signature); font-size: 2rem; color: var(--ink-900); line-height: 1.1; min-height: 2.4rem; }
.sig-preview__text.is-alt { font-family: var(--font-signature-alt); }
.sig-preview__initials { font-family: var(--font-signature); font-size: 1.5rem; color: var(--ink-900); }
.sig-preview__initials.is-alt { font-family: var(--font-signature-alt); }

.pad-block { margin-bottom: 1rem; }
.pad-block__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .4rem; }
.pad-block__head label { font-size: .78rem; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .04em; }
.pad-canvas-wrap { border: 1.5px dashed var(--border-strong); border-radius: var(--radius-sm); background: var(--surface-alt); position: relative; }
.pad-canvas-wrap canvas { display: block; width: 100%; touch-action: none; cursor: crosshair; }
.pad-canvas-wrap .pad-baseline { position: absolute; left: 8%; right: 8%; bottom: 22%; height: 1px; background: var(--border-strong); }

.inline-popover {
  position: absolute; z-index: 80; background: var(--surface); border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg); padding: .9rem; width: 250px; border: 1px solid var(--border);
}
.inline-popover__title { font-size: .78rem; font-weight: 700; color: var(--text-secondary); margin-bottom: .5rem; text-transform: uppercase; letter-spacing: .03em; }
.inline-popover__actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .7rem; }

/* Done / unavailable screens */
.centered-page {
  min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: radial-gradient(1200px 800px at 15% -10%, #eef2fb 0%, transparent 60%), var(--surface-alt);
}
.centered-card {
  max-width: 480px; width: 100%; background: var(--surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); padding: 2.4rem 2.2rem; text-align: center;
  animation: cardIn .4s cubic-bezier(.2, .8, .25, 1);
}
.success-icon { margin: 0 auto 1.2rem; background: linear-gradient(180deg, #23b073, var(--green)); }
.centered-card h1 { font-size: 1.4rem; margin-bottom: .5rem; }
.centered-card p.lead { color: var(--text-secondary); font-size: .94rem; margin-bottom: 1.6rem; line-height: 1.5; }
.receipt-box {
  text-align: left; background: var(--surface-alt); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 1rem 1.1rem; margin-bottom: 1.6rem; font-size: .82rem;
}
.receipt-row { display: flex; justify-content: space-between; padding: .25rem 0; }
.receipt-row .k { color: var(--text-tertiary); }
.receipt-row .v { font-weight: 600; }

.unavailable-icon { background: linear-gradient(180deg, #4a5568, var(--ink-800)); margin: 0 auto 1.2rem; }

/* --------------------------------------------------------------------------
   Misc
   -------------------------------------------------------------------------- */
.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, .35); border-top-color: #fff;
  animation: spin .7s linear infinite;
}
.spinner--dark { border-color: rgba(23, 29, 46, .18); border-top-color: var(--ink-900); }
@keyframes spin { to { transform: rotate(360deg); } }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

@media (max-width: 720px) {
  .prep-palette { width: 78px; }
  .prep-palette h3, .palette-chip span:not(.palette-count), .palette-hint { display: none; }
  .sign-progress-wrap { display: none; }
  .doc-card__head { flex-direction: column; align-items: flex-start; }
  .env-table thead { display: none; }
  .env-table, .env-table tbody, .env-table tr, .env-table td { display: block; width: 100%; }
  .env-table td { border-bottom: none; padding: .2rem 1.2rem; }
  .env-table tr { padding: .8rem 0; border-bottom: 1px solid var(--border); }
}
