/* e-Sign — documents, templates, the send flow and the field builder.
   Split out of index.html with esign.js. Built on the app's own tokens
   (--bg, --bg2, --bg3, --text*, --border*, --navy, --accent, --shadow-*,
   --radius-lg, --chart-track). The few values the e-Sign design names that
   the app has no token for are declared once below, never inline. */

#page-esign, .es-portal, #es-list-menu {
  /* Status colours: the same palette as the Applications page pills
     (.app-kpi-approved / -pending / -denied), under the design system's names. */
  --status-approved-bg: #e8f5e2; --status-approved-ink: #2d6a1f; --status-approved-line: #b8dda8;
  --status-pending-bg: #fef3e2;  --status-pending-ink: #854f0b;  --status-pending-line: #f5d9a0;
  --status-denied-bg: #fdecea;   --status-denied-ink: #a32d2d;   --status-denied-line: #f5b8b8;
  --es-sent-ink: #1d4ed8; --es-sent-line: rgba(37, 99, 235, 0.25);
  --es-success: #15803d; --es-amber: #92400e; --es-amber-dot: #c68a1a; --es-error: #b91c1c;
  --es-avatar-tint: #e3e9f9; --es-avatar-ink: #2563eb;
  --es-popover: #14142a;
  --es-scrim: rgba(20, 20, 42, 0.42);
  --es-hover: rgba(37, 99, 235, 0.07);
  --es-ring: 0 0 0 3px rgba(37, 99, 235, 0.12);
  --es-ease: cubic-bezier(.2, .8, .2, 1);
}
[data-theme="dark"] #page-esign, [data-theme="dark"] .es-portal, [data-theme="dark"] #es-list-menu {
  --status-approved-bg: rgba(45, 106, 31, 0.22); --status-approved-ink: #8fd07a; --status-approved-line: rgba(143, 208, 122, 0.35);
  --status-pending-bg: rgba(133, 79, 11, 0.24);  --status-pending-ink: #f0bf6a;  --status-pending-line: rgba(240, 191, 106, 0.35);
  --status-denied-bg: rgba(90, 36, 48, 0.25);    --status-denied-ink: #e08a96;   --status-denied-line: rgba(224, 138, 150, 0.35);
  --es-sent-ink: #93b4ff; --es-sent-line: rgba(147, 180, 255, 0.3);
  --es-success: #6ad08a; --es-amber: #f0bf6a; --es-error: #f08a8a;
  --es-avatar-tint: rgba(79, 139, 232, 0.2); --es-avatar-ink: #93b4ff;
}

#page-esign { background: var(--bg2); }
#page-esign *, .es-portal * { -webkit-tap-highlight-color: transparent; }
.es-root { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }
.es-hidden { display: none !important; }
.es-btn-reset { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; text-align: inherit; }
#page-esign :focus-visible, .es-portal :focus-visible { outline: 2px solid rgba(37, 99, 235, 0.55); outline-offset: 1px; }

/* Press feedback: on pointer-down, spring back on release. */
.es-press { transition: transform .16s var(--es-ease), background .12s, box-shadow .16s, border-color .12s; }
.es-press:active { transform: scale(0.985); transition-duration: .08s; }

/* ── Header (desktop) ─────────────────────────────────────────────── */
#page-esign .es-topbar { flex-shrink: 0; }
.es-head-tabs { display: flex; align-items: baseline; gap: 20px; }
.es-head-tab { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; color: rgba(255, 255, 255, 0.62); cursor: pointer; transition: color .15s; }
.es-head-tab:hover, .es-head-tab.on { color: #fff; }
.es-crumb { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 600; letter-spacing: -0.01em; color: #fff; min-width: 0; }
.es-crumb .es-crumb-back { color: rgba(255, 255, 255, 0.65); cursor: pointer; }
.es-crumb .es-crumb-back:hover { color: #fff; }
.es-crumb .es-crumb-sep { color: rgba(255, 255, 255, 0.45); font-weight: 400; }
.es-crumb .es-crumb-here { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Expanding search pill: 34px square, opens to 240px on hover/focus/text. */
.es-search { position: relative; width: 34px; height: 34px; flex: 0 0 34px; }
.es-search-pill {
  position: absolute; top: 0; right: 0; height: 34px; box-sizing: border-box; z-index: 5;
  display: flex; align-items: center; justify-content: center; gap: 0; overflow: hidden; cursor: pointer;
  width: 34px; padding: 0; border-radius: 9px;
  /* Header buttons share one look app-wide: same fill, border and hover as the search box on Units/Contacts/Tasks. */
  background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(26, 26, 46, 0.12);
  -webkit-backdrop-filter: none; backdrop-filter: none;
  transition: width .18s cubic-bezier(.4, 0, .2, 1), border-radius .18s cubic-bezier(.4, 0, .2, 1), padding .18s cubic-bezier(.4, 0, .2, 1), background .15s;
}
.es-search-pill:hover { background: rgba(26, 26, 46, 0.10); }
.es-search-pill svg { width: 15px; height: 15px; flex-shrink: 0; color: #1a1a2e; }
.es-search-pill input { border: 0; background: transparent; outline: none; font: inherit; font-size: 13px; color: #14264a; min-width: 0; padding: 0; flex: 0 0 0; width: 0; opacity: 0; transition: opacity .12s linear; }
.es-search-pill input::placeholder { color: rgba(20, 38, 74, 0.55); }
.es-search:hover .es-search-pill, .es-search.open .es-search-pill, .es-search:focus-within .es-search-pill {
  width: 240px; padding: 0 12px 0 13px; border-radius: 999px; justify-content: flex-start; gap: 6px;
  background: rgba(255, 255, 255, 0.30); border-color: rgba(26, 26, 46, 0.12);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
[data-theme="dark"] .es-search-pill { background: rgba(255, 255, 255, 0.05); border-color: rgba(255, 255, 255, 0.10); }
[data-theme="dark"] .es-search-pill:hover { background: rgba(255, 255, 255, 0.13); }
.es-search:hover .es-search-pill input, .es-search.open .es-search-pill input, .es-search:focus-within .es-search-pill input { flex: 1 1 auto; width: 100%; opacity: 1; }
#page-esign .es-topbar .tb-kebab[aria-expanded="true"] { background: rgba(26, 26, 46, 0.10); }

/* The ⋮ menu (dark popover, the app's .tb-kebab-menu). */
#es-list-menu { width: 212px; max-width: 212px; padding: 10px; gap: 6px; border-radius: 14px; background: var(--es-popover); }
#es-list-menu .es-mi { display: flex; align-items: center; justify-content: center; gap: 8px; height: 38px; border-radius: 8px; font: inherit; font-size: 13px; color: #fff; border: 1px solid rgba(255, 255, 255, 0.10); background: rgba(255, 255, 255, 0.05); cursor: pointer; }
#es-list-menu .es-mi:hover { background: rgba(255, 255, 255, 0.10); }
#es-list-menu .es-mi.on { border-color: rgba(96, 165, 250, 0.7); background: rgba(79, 139, 232, 0.22); }
#es-list-menu .es-mi svg { width: 14px; height: 14px; }
#es-list-menu .es-menu-label { font-size: 10px; font-weight: 600; letter-spacing: 0.08em; color: rgba(255, 255, 255, 0.6); padding: 8px 2px 0; text-transform: uppercase; }
#es-list-menu select { width: 100%; height: 38px; padding: 0 10px; border-radius: 8px; border: 0; background: #fff; color: #18181b; font: inherit; font-size: 14px; outline: none; }

/* ── Status pills (fixed equal widths) ───────────────────────────── */
.es-pill { display: inline-block; box-sizing: border-box; text-align: center; padding: 3px 0; border-radius: 20px; font-size: 11px; font-weight: 500; white-space: nowrap; border: 1px solid transparent; }
.es-pill.w88 { width: 88px; flex: 0 0 88px; }
.es-pill.w76 { width: 76px; flex: 0 0 76px; }
.es-pill.w80 { width: 80px; flex: 0 0 80px; }
.es-pill.s-completed, .es-pill.s-signed { background: var(--status-approved-bg); color: var(--status-approved-ink); border-color: var(--status-approved-line); }
.es-pill.s-partially_signed, .es-pill.s-waiting, .es-pill.s-nofields { background: var(--status-pending-bg); color: var(--status-pending-ink); border-color: var(--status-pending-line); }
.es-pill.s-sent, .es-pill.s-fields { background: var(--accent-soft); color: var(--es-sent-ink); border-color: var(--es-sent-line); }
.es-pill.s-draft, .es-pill.s-upnext { background: var(--bg3); color: var(--text2); border-color: var(--border2); }
.es-pill.s-void { background: var(--status-denied-bg); color: var(--status-denied-ink); border-color: var(--status-denied-line); }
/* Desktop table chip: 128px, uppercase, with a 2px progress bar under it. */
.es-chip-old { display: block; width: 128px; box-sizing: border-box; text-align: center; padding: 3px 10px; border-radius: 99px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 500; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12); border: 1px solid transparent; }
.es-chip-old.s-completed { background: rgba(21, 128, 61, 0.10); color: var(--es-success); border-color: rgba(21, 128, 61, 0.30); }
.es-chip-old.s-partially_signed { background: var(--gold-soft); color: var(--gold); border-color: rgba(201, 168, 99, 0.30); }
.es-chip-old.s-sent { background: rgba(79, 139, 232, 0.10); color: #4f8be8; border-color: rgba(79, 139, 232, 0.30); }
.es-chip-old.s-draft { background: rgba(168, 162, 158, 0.10); color: var(--text3); border-color: rgba(168, 162, 158, 0.25); }
.es-bar { width: 128px; height: 2px; margin-top: 7px; border-radius: 2px; background: var(--chart-track); overflow: hidden; }
.es-bar > i { display: block; height: 100%; border-radius: 2px; }
.es-bar > i.s-completed { background: var(--es-success); }
.es-bar > i.s-partially_signed { background: var(--gold); }
.es-bar > i.s-sent { background: #4f8be8; }

/* ── Desktop documents list ───────────────────────────────────────── */
.es-list-wrap { flex: 1; min-height: 0; overflow: hidden; padding: 22px; display: flex; flex-direction: column; position: relative; }
.es-pane { position: absolute; inset: 0; display: flex; flex-direction: column; transition: opacity .22s ease, transform .26s cubic-bezier(.32, .72, 0, 1); }
.es-pane.off-left { opacity: 0; transform: translateX(-14px); pointer-events: none; }
.es-pane.off-right { opacity: 0; transform: translateX(14px); pointer-events: none; }
.es-panes { position: relative; flex: 1; min-height: 0; }
.es-upload-strip { font: inherit; background: none; display: flex; align-items: center; justify-content: center; gap: 10px; border: 1.5px dashed var(--border2); border-radius: var(--radius-lg); height: 40px; box-sizing: border-box; padding: 0 20px; margin-bottom: 12px; font-size: 13px; color: var(--text3); flex-shrink: 0; cursor: pointer; user-select: none; transition: border-color .15s, background .15s, color .15s; width: 100%; }
.es-upload-strip:hover { border-color: var(--accent); background: rgba(79, 139, 232, 0.04); color: var(--text2); }
.es-upload-strip:active { border-style: solid; background: rgba(79, 139, 232, 0.08); color: var(--text); }
.es-upload-strip svg { width: 16px; height: 16px; opacity: 0.55; }
.es-link { color: var(--accent); font-weight: 500; }
.es-table { --cols: minmax(0, 1fr) 172px 172px 172px 44px; border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-md); background: var(--bg); min-height: 0; flex: 1; display: flex; flex-direction: column; }
.es-thead { display: grid; grid-template-columns: var(--cols); padding: 10px 23px; font-size: 11px; color: var(--text); text-transform: uppercase; letter-spacing: 0.6px; font-weight: 700; border-bottom: 1px solid var(--border); background: var(--bg2); flex-shrink: 0; }
.es-thead > span:not(:first-child) { text-align: center; }
.es-tbody { overflow-y: auto; min-height: 0; padding: 4px 0; flex: 1; }
.es-row { display: grid; grid-template-columns: var(--cols); align-items: center; height: 76px; box-sizing: border-box; padding: 0 14px; margin: 2px 8px; border-radius: 12px; border: 1px solid transparent; font-size: 13px; cursor: pointer; transition: background .12s, border-color .12s; position: relative; }
.es-row:hover { background: var(--es-hover); border-color: rgba(37, 99, 235, 0.28); }
.es-row:focus-visible { outline: none; background: var(--es-hover); border-color: rgba(37, 99, 235, 0.55); }
.es-row:active { background: rgba(37, 99, 235, 0.10); border-color: rgba(37, 99, 235, 0.35); transform: translateY(0.5px); }
.es-row-doc { padding-right: 44px; min-width: 0; }
.es-row-title { font-weight: 500; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.es-row-sub { font-size: 11px; color: var(--text3); margin-top: 2px; display: flex; align-items: center; flex-wrap: wrap; }
.es-row-sub > span { white-space: nowrap; }
.es-row-sub .es-narrow { margin-left: 8px; display: none; }
.es-tag { display: inline-flex; align-items: center; gap: 4px; margin-left: 8px; font-size: 10px; font-weight: 500; border: 0; background: none; padding: 0; font-family: inherit; cursor: pointer; }
.es-tag svg { width: 10px; height: 10px; }
.es-tag.linked { color: var(--es-success); }
.es-tag.unlinked { color: var(--es-amber); }
.es-tag:hover { text-decoration: underline; }
.es-cell-status { display: flex; flex-direction: column; align-items: center; }
.es-cell-signers { position: relative; cursor: default; width: 128px; margin: 0 auto; display: flex; flex-direction: column; align-items: center; }
.es-stack { position: relative; display: flex; align-items: center; justify-content: center; }
.es-av { position: relative; flex: 0 0 30px; width: 30px; height: 30px; border-radius: 9px; box-sizing: border-box; display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; letter-spacing: 0.01em; border: 2px solid var(--bg); background: var(--bg3); color: var(--text3); }
.es-av + .es-av { margin-left: -6px; }
.es-av.signed { background: var(--es-avatar-tint); color: var(--es-avatar-ink); }
.es-more { position: absolute; left: 100%; top: 50%; transform: translateY(-50%); margin-left: 8px; white-space: nowrap; font-size: 11px; font-weight: 500; color: var(--text3); }
.es-sigpop { position: absolute; left: 50%; transform: translateX(-50%); top: calc(100% - 4px); z-index: 35; width: 220px; box-sizing: border-box; padding: 6px; background: var(--bg); border: 1px solid var(--border2); border-radius: 12px; box-shadow: var(--shadow-lg); display: none; }
.es-cell-signers:hover .es-sigpop, .es-cell-signers:focus-within .es-sigpop { display: block; }
.es-row.up .es-sigpop { top: auto; bottom: calc(100% + 2px); }
.es-sigpop-row { display: flex; align-items: center; gap: 10px; padding: 6px 8px; font-size: 12px; text-align: left; }
.es-sigpop-row .es-av { flex: 0 0 24px; width: 24px; height: 24px; border-radius: 8px; border: 0; font-size: 10px; margin: 0; }
.es-sigpop-name { flex: 1; min-width: 0; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.es-sigpop-st { font-size: 11px; font-weight: 500; white-space: nowrap; color: var(--text3); }
.es-sigpop-st.done { color: var(--es-success); }
.es-sigpop-more { font-size: 11px; color: var(--text3); padding: 4px 8px 2px; }
.es-cell-updated { font-size: 12px; line-height: 1.45; text-align: center; width: 128px; margin: 0 auto; }
.es-cell-updated .d { display: flex; align-items: center; justify-content: center; gap: 5px; color: var(--text2); }
.es-cell-updated .d.stale { color: var(--es-amber); font-weight: 500; }
.es-cell-updated .d.stale::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--es-amber-dot); flex-shrink: 0; }
.es-cell-updated .t { color: var(--text3); }
.es-cell-act { position: relative; display: flex; justify-content: flex-end; align-items: center; }
.es-kebab { width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; color: var(--text2); border-radius: 6px; cursor: pointer; border: 0; background: none; padding: 0; }
.es-kebab:hover { background: var(--es-hover); }
.es-kebab svg { width: 15px; height: 15px; }
/* Narrow content: Updated, then Signers, fold into the row's sub-line — at the
   design's 1000px and 800px board widths (board = 153px sidebar + this area). */
@container eslist (max-width: 802px) {
  .es-table { --cols: minmax(0, 1fr) 172px 172px 44px; }
  .es-col-updated { display: none !important; }
  .es-row-sub .es-narrow.u { display: inline; }
}
@container eslist (max-width: 602px) {
  .es-table { --cols: minmax(0, 1fr) 172px 44px; }
  .es-col-signers { display: none !important; }
  .es-row-sub .es-narrow.s { display: inline; }
}
.es-list-wrap { container: eslist / inline-size; }

/* Row / document menu (popover, 232px). */
.es-pop { position: fixed; z-index: 3200; width: 232px; box-sizing: border-box; padding: 5px; background: var(--bg); border: 1px solid var(--border2); border-radius: 12px; box-shadow: var(--shadow-lg); font-family: inherit; }
.es-pop-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 8px; font: inherit; font-size: 13px; color: var(--text); cursor: pointer; border: 0; background: none; text-align: left; }
.es-pop-item:hover, .es-pop-item:focus-visible { background: var(--es-hover); outline: none; }
.es-pop-item svg { width: 15px; height: 15px; color: var(--text2); flex-shrink: 0; }
.es-pop-item.danger, .es-pop-item.danger svg { color: var(--danger); }
.es-pop-item.danger:hover { background: var(--danger-soft); }
.es-pop-sep { height: 1px; background: var(--border); margin: 5px 4px; }
.es-pop-confirm { padding: 6px 8px 4px; }
.es-pop-confirm p { font-size: 12px; color: var(--text); line-height: 1.4; margin: 0 0 8px; }
.es-pop-confirm .row { display: flex; gap: 6px; }
.es-pop-confirm .es-btn-sm { flex: 1; text-align: center; padding: 7px 0; border-radius: 8px; border: 1px solid var(--border2); font: inherit; font-size: 12px; font-weight: 500; cursor: pointer; background: var(--bg); color: var(--text); }
.es-pop-confirm .es-btn-sm:hover { background: var(--bg2); }
.es-pop-confirm .es-btn-sm.void { background: var(--status-denied-bg); border-color: var(--status-denied-line); color: var(--status-denied-ink); }

/* Empty / loading / error */
.es-empty { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 56px 20px; color: var(--text3); }
.es-empty > svg { width: 30px; height: 30px; opacity: 0.45; }
.es-empty-title { margin-top: 10px; font-size: 14px; font-weight: 500; color: var(--text); }
.es-empty-body { margin-top: 4px; font-size: 12px; color: var(--text2); max-width: 320px; }
.es-empty-cta { margin-top: 14px; padding: 8px 14px; border: 1px solid var(--border2); border-radius: 8px; font: inherit; font-size: 13px; font-weight: 500; color: var(--text); cursor: pointer; background: var(--bg); box-shadow: var(--shadow-xs); }
.es-empty-cta:hover { background: var(--bg2); }

/* Drag a file onto the page */
.es-drop { position: absolute; inset: 0; z-index: 20; pointer-events: none; box-sizing: border-box; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; border-radius: var(--radius-lg); border: 2px dashed var(--accent); background: rgba(250, 249, 246, 0.92); opacity: 0; transition: opacity .15s ease; }
.es-drop.on { opacity: 1; }
.es-drop-icon { width: 56px; height: 56px; border-radius: 16px; display: flex; align-items: center; justify-content: center; margin-bottom: 6px; background: var(--es-avatar-tint); color: var(--es-avatar-ink); transform: translateY(8px) scale(0.92); transition: transform .2s cubic-bezier(.32, .72, 0, 1); }
.es-drop.on .es-drop-icon { transform: none; }
.es-drop-icon svg { width: 26px; height: 26px; }
.es-drop-title { font-size: 17px; font-weight: 500; color: var(--text); letter-spacing: -0.01em; }
.es-drop-sub { font-size: 13px; color: var(--text2); }
[data-theme="dark"] .es-drop { background: rgba(20, 28, 46, 0.92); }

/* Templates tab (desktop) */
.es-tpl-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; color: var(--text3); font-size: 13px; padding: 20px 20px 92px; }
.es-tpl-empty > svg { width: 32px; height: 32px; opacity: 0.4; }
.es-tpl-empty-title { margin-top: 10px; font-weight: 500; color: var(--text3); }
.es-tpl-empty-body { font-size: 12px; color: var(--text3); margin-top: 4px; max-width: 360px; }
.es-btn-primary { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 34px; padding: 0 14px; border-radius: 8px; font: inherit; font-size: 13px; font-weight: 500; color: #fff; background: var(--accent); border: 1px solid var(--accent); cursor: pointer; box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.18); }
.es-btn-primary svg { width: 14px; height: 14px; }
.es-btn-primary[disabled], .es-btn-primary.off { opacity: 0.4; cursor: not-allowed; }
.es-btn-ghost { display: inline-flex; align-items: center; height: 38px; padding: 0 12px; border-radius: 8px; font: inherit; font-size: 13px; font-weight: 500; color: var(--text2); cursor: pointer; background: none; border: 0; }
.es-btn-ghost:hover { color: var(--text); background: var(--bg3); }
.es-btn-line { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--border2); background: var(--bg); font: inherit; font-size: 13px; font-weight: 500; color: var(--text); box-shadow: var(--shadow-xs); cursor: pointer; }
.es-btn-line:hover { background: var(--bg2); }
.es-tpl-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; max-width: 760px; width: 100%; margin: 0 auto; }
.es-tpl-head { display: flex; justify-content: flex-end; }
.es-tpl-card { flex-shrink: 0; display: flex; align-items: center; gap: 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-xs); padding: 14px; cursor: pointer; text-align: left; width: 100%; font: inherit; color: inherit; }
.es-tpl-card:hover { border-color: rgba(37, 99, 235, 0.28); }
.es-tpl-icon { flex: 0 0 40px; width: 40px; height: 40px; border-radius: 12px; background: var(--es-avatar-tint); color: var(--es-avatar-ink); display: flex; align-items: center; justify-content: center; }
.es-tpl-icon svg { width: 19px; height: 19px; }
.es-tpl-main { flex: 1; min-width: 0; }
.es-tpl-name { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.es-tpl-meta { font-size: 12px; color: var(--text2); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Template upload step ─────────────────────────────────────────── */
.es-step-scroll { flex: 1; min-height: 0; overflow: auto; padding: 28px 22px 24px; display: flex; justify-content: center; align-items: flex-start; }
.es-step-col { width: 100%; max-width: 600px; display: flex; flex-direction: column; gap: 22px; }
.es-progress { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.es-progress > div > i { display: block; height: 3px; border-radius: 2px; background: var(--border2); }
.es-progress > div.on > i, .es-progress > div.done > i { background: var(--navy); }
.es-progress > div > span { display: block; margin-top: 8px; font-size: 12px; color: var(--text2); }
.es-progress > div.on > span { font-weight: 500; color: var(--text); }
.es-h1 { font-size: 26px; font-weight: 500; letter-spacing: -0.02em; line-height: 1.2; color: var(--text); margin: 0; }
.es-h1-sub { font-size: 14px; color: var(--text2); margin-top: 4px; line-height: 1.5; }
.es-card { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); overflow: hidden; }
.es-card-sec { padding: 20px 24px; }
.es-card-sec + .es-card-sec { border-top: 1px solid var(--border); }
.es-card-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 14px 24px; background: var(--bg2); border-top: 1px solid var(--border); }
.es-label { font-size: 12px; font-weight: 500; color: var(--text); margin-bottom: 6px; display: flex; align-items: baseline; gap: 6px; }
.es-label .opt { font-weight: 400; color: var(--text2); }
.es-input { width: 100%; box-sizing: border-box; height: 40px; padding: 0 12px; font: inherit; font-size: 14px; color: var(--text); background: var(--bg); border: 1px solid var(--border2); border-radius: 8px; outline: none; transition: border-color .12s, box-shadow .12s; }
.es-input:focus { border-color: var(--accent); box-shadow: var(--es-ring); }
.es-help { font-size: 12px; color: var(--text2); margin-top: 6px; }
.es-fields-stack { display: flex; flex-direction: column; gap: 16px; }
.es-dz { height: 140px; box-sizing: border-box; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; cursor: pointer; border-radius: 12px; border: 1.5px dashed var(--border2); background: var(--bg2); transition: border-color .15s, background .15s; width: 100%; font: inherit; color: inherit; }
.es-dz:hover { border-color: var(--accent); background: rgba(79, 139, 232, 0.05); }
.es-dz.drag { border-style: solid; border-color: var(--accent); background: rgba(79, 139, 232, 0.08); }
.es-dz-icon { width: 52px; height: 52px; border-radius: 15px; background: var(--bg); border: 1px solid var(--border2); color: var(--accent); display: flex; align-items: center; justify-content: center; box-shadow: 0 0 0 7px rgba(37, 99, 235, 0.06), var(--shadow-xs); }
.es-dz-icon svg { width: 22px; height: 22px; }
.es-dz-title { margin-top: 6px; font-size: 14px; font-weight: 500; color: var(--text); text-align: center; white-space: nowrap; }
.es-dz-sub { font-size: 12px; color: var(--text2); }
.es-dz-err { display: flex; justify-content: space-between; margin-top: 10px; min-height: 16px; font-size: 12px; color: var(--es-error); }
.es-file { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border: 1px solid var(--border2); border-radius: 12px; background: var(--bg); box-shadow: var(--shadow-xs); }
.es-thumb { flex: 0 0 38px; width: 38px; height: 48px; box-sizing: border-box; border-radius: 4px; background: #fff; border: 1px solid var(--border2); box-shadow: var(--shadow-xs); padding: 7px 6px; display: flex; flex-direction: column; gap: 4px; }
.es-thumb i { display: block; height: 2px; border-radius: 1px; background: var(--border2); }
.es-thumb i:first-child { height: 3px; width: 60%; border-radius: 2px; background: var(--navy); }
.es-thumb i:last-child { margin-top: auto; height: 3px; width: 45%; border-radius: 2px; background: var(--accent); opacity: 0.7; }
.es-file-main { flex: 1; min-width: 0; }
.es-file-name { font-size: 14px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.es-file-meta { display: flex; align-items: center; gap: 8px; margin-top: 4px; font-size: 12px; color: var(--text2); }
.es-uploaded { font-size: 11px; font-weight: 500; padding: 2px 8px; border-radius: 20px; background: var(--status-approved-bg); color: var(--status-approved-ink); border: 1px solid var(--status-approved-line); }
.es-x { color: var(--text3); padding: 6px; border-radius: 6px; cursor: pointer; line-height: 1; border: 0; background: none; display: inline-flex; }
.es-x:hover { color: var(--danger); background: var(--danger-soft); }
.es-x svg { width: 15px; height: 15px; }

/* ── Builder (desktop) ────────────────────────────────────────────── */
.es-builder { flex: 1; min-height: 0; display: grid; grid-template-columns: 288px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); gap: 14px; padding: 14px 18px; overflow: hidden; }
.es-side { display: flex; flex-direction: column; min-height: 0; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); overflow: hidden; }
.es-side-name { flex-shrink: 0; padding: 14px 14px 4px; }
.es-cap { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text2); margin: 0 2px 4px; }
.es-side-name input { width: 100%; box-sizing: border-box; height: 34px; padding: 0 10px; font: inherit; font-size: 13px; font-weight: 500; color: var(--text); background: var(--bg); border: 1px solid var(--border2); border-radius: 8px; outline: none; text-overflow: ellipsis; }
.es-side-name input:focus { border-color: var(--accent); }
.es-side-tabs { display: flex; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.es-side-tab { flex: 1; justify-content: center; padding: 12px 10px 11px; font: inherit; font-size: 13px; cursor: pointer; display: flex; align-items: center; gap: 7px; margin-bottom: -1px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--text2); }
.es-side-tab.on { border-bottom-color: var(--navy); color: var(--text); font-weight: 500; }
.es-side-tab .n { font-size: 11px; font-weight: 400; line-height: 1; color: var(--text2); }
.es-side-body { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 12px; }
.es-side-foot { flex-shrink: 0; border-top: 1px solid var(--border); padding: 12px; background: var(--bg); display: flex; flex-direction: column; gap: 10px; }
.es-checks { display: flex; flex-direction: column; gap: 5px; }
.es-check { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text2); }
.es-check-dot { width: 14px; height: 14px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 14px; background: var(--bg3); color: var(--text3); }
.es-check-dot svg { width: 9px; height: 9px; }
.es-check.ok .es-check-dot { background: rgba(21, 128, 61, 0.12); color: var(--es-success); }
.es-status-line { display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: var(--text2); padding: 0 2px; }
.es-status-line > span:last-child { display: inline-flex; align-items: center; gap: 6px; color: var(--text); }
.es-status-line > span:last-child::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--text3); }
.es-order { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 2px; cursor: pointer; border: 0; background: none; font: inherit; text-align: left; width: 100%; color: inherit; }
.es-order-t { font-size: 12px; font-weight: 500; color: var(--text); }
.es-order-s { font-size: 11px; color: var(--text2); margin-top: 1px; }
.es-switch { position: relative; flex: 0 0 34px; width: 34px; height: 20px; border-radius: 10px; transition: background .15s; background: var(--chart-track); }
.es-switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); transition: left .15s; }
.es-switch.on { background: var(--accent); }
.es-switch.on::after { left: 16px; }
.es-send { display: flex; align-items: center; justify-content: center; gap: 7px; height: 38px; border-radius: 8px; font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; transition: opacity .15s; background: var(--bg); color: var(--text3); border: 1px solid var(--border2); box-shadow: var(--shadow-xs); }
.es-send.ready { background: rgba(37, 99, 235, 0.06); color: var(--accent); border-color: var(--accent); }
.es-send:not(.ready) { cursor: not-allowed; }
.es-send svg { width: 14px; height: 14px; }
.es-confirm-inline { display: flex; flex-direction: column; gap: 8px; }
.es-confirm-inline .t { font-size: 13px; font-weight: 500; color: var(--text); }
.es-confirm-inline .b { font-size: 12px; color: var(--text2); line-height: 1.4; }
.es-confirm-inline textarea { width: 100%; box-sizing: border-box; padding: 8px 10px; font: inherit; font-size: 13px; line-height: 1.4; color: var(--text); background: var(--bg); border: 1px solid var(--border2); border-radius: 8px; outline: none; resize: none; }
.es-confirm-inline textarea:focus { border-color: var(--accent); box-shadow: var(--es-ring); }
.es-confirm-inline .row { display: flex; gap: 8px; }
.es-confirm-inline .row > * { flex: 1; }

/* Recipient / role cards (desktop) */
.es-rlist { position: relative; }
.es-rrow { display: flex; gap: 8px; position: relative; }
.es-rail { flex: 0 0 20px; width: 20px; display: flex; flex-direction: column; align-items: center; }
.es-rail-n { width: 20px; height: 20px; border-radius: 50%; box-sizing: border-box; display: inline-flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 600; font-family: 'DM Mono', monospace; background: var(--bg); border: 1px solid var(--border2); color: var(--text2); }
.es-rrow.on .es-rail-n { border-color: var(--accent); color: var(--accent); }
.es-rail-line { flex: 1; width: 2px; margin-top: 4px; border-radius: 1px; background: var(--border2); }
.es-rrow:last-child .es-rail-line { display: none; }
.es-rcard { flex: 1; min-width: 0; border: 1px solid var(--border2); border-radius: 12px; padding: 10px; background: var(--bg); margin-bottom: 8px; cursor: text; position: relative; transition: border-color .12s, background .12s; }
.es-rcard.grip { padding-left: 24px; }
.es-rcard:hover { border-color: rgba(37, 99, 235, 0.28); }
.es-rrow.on .es-rcard { border-color: rgba(37, 99, 235, 0.45); background: rgba(37, 99, 235, 0.04); }
.es-grip { position: absolute; top: 10px; left: 4px; width: 16px; height: 22px; border-radius: 5px; color: var(--text3); display: flex; align-items: center; justify-content: center; cursor: grab; z-index: 2; touch-action: none; border: 0; background: none; padding: 0; }
.es-grip:hover { color: var(--accent); background: rgba(37, 99, 235, 0.08); }
.es-grip svg { width: 11px; height: 11px; }
.es-rhead { display: flex; align-items: center; gap: 10px; }
.es-ravatar { box-sizing: border-box; border: 2px solid var(--c); width: 34px; height: 34px; border-radius: 10px; flex: 0 0 34px; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; background: var(--es-avatar-tint); color: var(--es-avatar-ink); }
.es-rinputs { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.es-rinputs input { width: 100%; box-sizing: border-box; padding: 2px 0; font: inherit; color: var(--text); border: 0; border-bottom: 1px solid transparent; background: none; outline: none; }
.es-rinputs input:focus { border-bottom-color: var(--accent); }
.es-rinputs .nm { font-size: 13px; font-weight: 500; }
.es-rinputs .em { font-size: 12px; color: var(--text2); }
.es-rinputs .em.bad { border-bottom-color: var(--danger); }
.es-rinputs .role { font-size: 11px; color: var(--text2); padding: 2px 0; }
.es-rdel { color: var(--text3); padding: 4px; border-radius: 6px; cursor: pointer; line-height: 1; align-self: flex-start; border: 0; background: none; display: inline-flex; }
.es-rdel:hover { color: var(--danger); background: var(--danger-soft); }
.es-rdel svg { width: 14px; height: 14px; }
.es-rbad { font-size: 11px; color: var(--danger); margin: 6px 0 0 44px; }
.es-rfoot { display: flex; align-items: center; justify-content: space-between; margin-top: 9px; padding-top: 8px; border-top: 1px solid var(--border); font-size: 11px; color: var(--text2); }
.es-rcount { font-weight: 500; cursor: pointer; padding: 2px 8px; border-radius: 99px; white-space: nowrap; flex-shrink: 0; border: 0; font: inherit; font-size: 11px; background: rgba(37, 99, 235, 0.08); color: var(--accent); }
.es-rcount.none { background: var(--status-pending-bg); color: var(--status-pending-ink); }
.es-add-row { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 10px; border: 1.5px dashed var(--border2); border-radius: 12px; font: inherit; font-size: 12px; font-weight: 500; color: var(--text2); cursor: pointer; transition: all .15s; background: none; width: 100%; }
.es-add-row:hover { border-color: var(--accent); background: rgba(37, 99, 235, 0.04); color: var(--text); }
.es-add-row svg { width: 14px; height: 14px; }
/* Reorder: the dragged card follows the pointer; siblings slide out of its way. */
.es-sortable > .es-drag-item { transition: transform .24s cubic-bezier(.2, .9, .3, 1); }
.es-sortable.dragging > .es-drag-item.lifted { transition: none; z-index: 5; transform: translateY(var(--dy, 0)) scale(1.02); }
.es-sortable.dragging > .es-drag-item.lifted .es-rcard, .es-sortable.dragging > .es-drag-item.lifted .es-mrole { box-shadow: 0 14px 30px rgba(20, 40, 100, 0.22); }
.es-sortable.settling > .es-drag-item.lifted { transition: transform .2s cubic-bezier(.2, .9, .3, 1); }

/* Fields tab (desktop) */
.es-assign { position: relative; margin-bottom: 14px; }
.es-assign select { width: 100%; height: 38px; box-sizing: border-box; padding: 0 30px 0 32px; font: inherit; font-size: 13px; color: var(--text); background: var(--bg); border: 1px solid var(--border2); border-radius: 8px; outline: none; appearance: none; -webkit-appearance: none; cursor: pointer; }
.es-assign .dot { position: absolute; left: 12px; top: 13px; width: 12px; height: 12px; border-radius: 50%; background: var(--c); pointer-events: none; }
.es-assign .chev { position: absolute; right: 10px; top: 12px; width: 14px; height: 14px; color: var(--text2); pointer-events: none; }
.es-fgroup { margin-bottom: 12px; }
.es-fitem { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 10px; cursor: grab; font: inherit; font-size: 13px; color: var(--text); user-select: none; border: 1px solid transparent; background: transparent; transition: background .12s, border-color .12s; width: 100%; text-align: left; touch-action: none; }
.es-fitem:hover { border-color: var(--border2); background: var(--bg3); }
.es-fitem.on { border-color: rgba(37, 99, 235, 0.45); background: rgba(37, 99, 235, 0.08); }
.es-fitem .box { width: 28px; height: 28px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 28px; background: var(--es-avatar-tint); color: var(--es-avatar-ink); }
.es-fitem.on .box { background: var(--accent); color: #fff; }
.es-fitem .box svg { width: 14px; height: 14px; }
.es-fitem .lbl { flex: 1; }
.es-fitem .cnt { font-size: 11px; font-weight: 600; color: var(--accent); font-family: 'DM Mono', monospace; }
.es-fitem .gr { width: 14px; height: 14px; color: var(--text3); opacity: 0.55; }
.es-hint { font-size: 10px; line-height: 1.4; text-align: center; padding: 8px; border-radius: 6px; border: 1px dashed var(--border2); color: var(--text3); background: var(--bg2); }
.es-hint.on { border: 1px solid var(--accent); color: var(--accent); background: rgba(79, 139, 232, 0.06); }

/* PDF canvas */
.es-canvas { min-height: 0; overflow: auto; padding: 0 8px 8px; }
.es-pages { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.es-page { position: relative; width: 100%; background: #fff center / 100% 100% no-repeat; border-radius: 4px; flex: 0 0 auto; user-select: none; -webkit-user-select: none; touch-action: pan-x pan-y; }
.es-page.placing { cursor: crosshair; }
.es-loading-page { width: 100%; max-width: 640px; aspect-ratio: 640 / 880; background: var(--bg); box-shadow: var(--shadow-lg); border-radius: 4px; display: flex; align-items: center; justify-content: center; font-size: 13px; color: var(--text2); }

/* A placed field. --fc is the recipient's colour, --s the page scale (page width / 640). */
.es-field { --tint: color-mix(in srgb, var(--fc) 12%, #fff); position: absolute; box-sizing: border-box; background: var(--tint); border: 1.5px solid var(--fc); border-radius: 5px; font-size: max(7px, calc(11px * var(--s, 1))); font-weight: 500; line-height: 1.1; color: var(--fc); display: flex; align-items: center; justify-content: flex-start; gap: 4px; padding: 0 4px; cursor: move; user-select: none; white-space: nowrap; font-family: 'DM Sans', sans-serif; overflow: visible; touch-action: none; }
.es-field > .lab { display: flex; align-items: center; gap: 4px; min-width: 0; max-width: 100%; overflow: hidden; }
.es-field > .lab span { overflow: hidden; text-overflow: ellipsis; }
.es-field > .lab svg { width: max(8px, calc(11px * var(--s, 1))); height: max(8px, calc(11px * var(--s, 1))); flex: 0 0 auto; }
.es-field.t-checkbox, .es-field.t-radio { justify-content: center; padding: 0; }
.es-field.t-radio { border-radius: 50%; }
.es-field.t-checkbox .lab span, .es-field.t-radio .lab span { display: none; }
.es-field.t-whiteout { background: #fff; border: 1px dashed #c9c9c9; border-radius: 0; }
.es-field.t-redact { background: #000; border-color: #000; border-radius: 0; }
.es-field.t-highlight { background: rgba(250, 204, 21, 0.45); border-color: transparent; border-radius: 0; mix-blend-mode: multiply; }
.es-field.t-annotation { background: transparent; border: 1.5px dashed rgba(68, 64, 60, 0.3); color: #111; }
.es-field.t-annotation.has-text:not(.sel) { border-color: transparent; }
.es-field.t-annotation input { width: 100%; min-width: 0; height: 100%; box-sizing: border-box; border: 0; outline: none; background: transparent; padding: 0; font-family: 'Times New Roman', Times, serif; font-size: max(9px, calc(13px * var(--s, 1))); color: #111; cursor: text; user-select: text; }
.es-field.t-whiteout > .lab, .es-field.t-redact > .lab, .es-field.t-highlight > .lab, .es-field.t-annotation > .lab { display: none; }
.es-field.sel { box-shadow: 0 0 0 3px color-mix(in srgb, var(--fc) 28%, transparent), 0 6px 16px rgba(0, 0, 0, 0.12); z-index: 10; }
.es-field.t-whiteout.sel, .es-field.t-redact.sel, .es-field.t-highlight.sel, .es-field.t-annotation.sel { box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.28), 0 6px 16px rgba(0, 0, 0, 0.12); }
.es-field.t-annotation.sel { border-color: var(--fc); }
.es-ftag { position: absolute; top: -9px; left: 8px; max-width: calc(100% - 16px); display: flex; align-items: center; gap: 4px; height: 16px; padding: 0 6px 0 5px; box-sizing: border-box; background: #fff; border: 1px solid var(--fc); border-radius: 99px; color: #18181b; font-size: 9px; font-weight: 600; letter-spacing: 0.02em; white-space: nowrap; pointer-events: none; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08); transform: scale(var(--s, 1)); transform-origin: 0 100%; }
.es-ftag::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--fc); flex: 0 0 6px; }
.es-ftag span { overflow: hidden; text-overflow: ellipsis; }
.es-ftb { position: absolute; bottom: calc(100% + 14px); left: 50%; transform: translateX(-50%); white-space: nowrap; z-index: 12; cursor: default; width: max-content; }
.es-ftb-in > * { flex: 0 0 auto; }
.es-ftb-in { display: flex; align-items: center; gap: 1px; padding: 3px; background: color-mix(in srgb, var(--fc) 12%, #fff); border: 1.5px solid var(--fc); border-radius: 8px; box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12); }
.es-ftb-in::after { content: ''; position: absolute; left: 50%; bottom: -5px; width: 8px; height: 8px; background: color-mix(in srgb, var(--fc) 12%, #fff); border-right: 1.5px solid var(--fc); border-bottom: 1.5px solid var(--fc); transform: translateX(-50%) rotate(45deg); }
.es-ftb button { width: 22px; height: 22px; border-radius: 6px; display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--fc); border: 0; background: none; padding: 0; transition: background .12s, color .12s; }
.es-ftb button:hover { background: color-mix(in srgb, var(--fc) 20%, #fff); }
.es-ftb button.del:hover { background: rgba(220, 38, 38, 0.12); color: var(--danger); }
.es-ftb button svg { width: 12px; height: 12px; }
.es-ftb .sep { width: 1px; height: 12px; background: color-mix(in srgb, var(--fc) 45%, transparent); margin: 0 2px; }
.es-ftb input { width: 170px; height: 22px; box-sizing: border-box; border: 1px solid color-mix(in srgb, var(--fc) 40%, transparent); border-radius: 6px; padding: 0 6px; font: inherit; font-size: 11px; color: #18181b; background: #fff; outline: none; margin-right: 2px; }
.es-handle { position: absolute; right: -5px; bottom: -5px; width: 9px; height: 9px; background: #fff; border: 1.5px solid var(--fc); border-radius: 2px; cursor: nwse-resize; box-sizing: border-box; touch-action: none; }
.es-ghost { position: fixed; z-index: 4000; pointer-events: none; box-sizing: border-box; display: flex; align-items: center; padding: 0 4px; overflow: hidden; white-space: nowrap; border-radius: 5px; font-size: 11px; font-weight: 500; font-family: 'DM Sans', sans-serif; background: color-mix(in srgb, var(--fc) 12%, #fff); border: 1.5px solid var(--fc); color: var(--fc); box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18); opacity: 0.94; }

/* ── Success + detail (shared) ────────────────────────────────────── */
.es-done { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 0 32px 60px; }
.es-done-icon { width: 72px; height: 72px; border-radius: 50%; background: var(--status-approved-bg); color: var(--es-success); display: flex; align-items: center; justify-content: center; box-shadow: 0 0 0 10px rgba(21, 128, 61, 0.08); }
.es-done-icon svg { width: 32px; height: 32px; }
.es-done-t { margin-top: 26px; font-size: 24px; font-weight: 500; letter-spacing: -0.02em; color: var(--text); }
.es-done-s { margin-top: 8px; font-size: 14px; line-height: 1.5; color: var(--text2); max-width: 290px; }
.es-done-btns { margin-top: 28px; width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 10px; }
.es-big { height: 50px; display: flex; align-items: center; justify-content: center; gap: 8px; border-radius: 12px; font: inherit; font-size: 15px; font-weight: 500; cursor: pointer; width: 100%; }
.es-big svg { width: 17px; height: 17px; }
.es-big.blue { background: var(--accent); color: #fff; border: 0; box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.18); }
.es-big.blue.off { opacity: 0.4; }
.es-big.line { border: 1px solid var(--border2); background: var(--bg); color: var(--text); box-shadow: var(--shadow-xs); }

.es-detail { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; }
.es-detail-head { padding: 6px 16px 16px; display: flex; flex-direction: column; gap: 10px; }
.es-detail-title { font-size: 18px; font-weight: 500; line-height: 1.35; letter-spacing: -0.01em; word-break: break-word; color: var(--text); }
.es-detail-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text2); white-space: nowrap; }
.es-tabs3 { flex-shrink: 0; display: flex; background: var(--bg2); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.es-tabs3 button { flex: 1 1 0; min-width: 0; text-align: center; font: inherit; font-size: 15px; color: var(--text2); padding: 12px 2px 11px; margin-bottom: -1px; border: 0; border-bottom: 2px solid transparent; background: none; cursor: pointer; }
.es-tabs3 button.on { color: var(--text); font-weight: 500; border-bottom-color: var(--navy); }
.es-tabbody { padding: 16px 14px 130px; display: flex; flex-direction: column; gap: 14px; }
.es-prev-page { width: 100%; background: #fff center / 100% 100% no-repeat; border: 1px solid var(--border); border-radius: 6px; box-shadow: var(--shadow-xs); }
.es-panel { background: var(--bg); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-xs); }
.es-prog { padding: 14px; }
.es-prog-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.es-prog-top b { font-size: 14px; font-weight: 500; color: var(--text); }
.es-prog-top span { font-size: 12px; color: var(--text2); text-align: right; }
.es-prog-bar { height: 4px; border-radius: 2px; background: var(--chart-track); margin-top: 10px; overflow: hidden; }
.es-prog-bar i { display: block; height: 100%; border-radius: 2px; background: var(--accent); }
.es-prog-bar i.done { background: var(--es-success); }
.es-plist { overflow: hidden; }
.es-prow { display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.es-prow + .es-prow { border-top: 1px solid var(--border); }
.es-prow .es-av { flex: 0 0 38px; width: 38px; height: 38px; border-radius: 10px; border: 0; font-size: 12px; margin: 0; }
.es-prow .es-ring { flex: 0 0 38px; width: 38px; height: 38px; border-radius: 10px; box-sizing: border-box; border: 2px solid var(--c); display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; background: var(--es-avatar-tint); color: var(--es-avatar-ink); }
.es-pmain { flex: 1; min-width: 0; }
.es-pname { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.es-psub { font-size: 12px; color: var(--text2); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.es-tl { padding: 18px 20px 130px; display: flex; flex-direction: column; }
.es-ev { display: flex; gap: 14px; }
.es-ev-rail { display: flex; flex-direction: column; align-items: center; flex: 0 0 20px; }
.es-ev-dot { flex: 0 0 20px; width: 20px; height: 20px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--es-avatar-tint); color: var(--es-avatar-ink); }
.es-ev-dot svg { width: 11px; height: 11px; }
.es-ev-dot.done { background: var(--status-approved-bg); color: var(--es-success); }
.es-ev-dot.wait { background: var(--status-pending-bg); color: var(--es-amber); }
.es-ev-dot.void { background: var(--status-denied-bg); color: var(--status-denied-ink); }
.es-ev-line { flex: 1; width: 2px; margin-top: 4px; border-radius: 1px; background: var(--border2); }
.es-ev:last-child .es-ev-line { display: none; }
.es-ev-body { padding-bottom: 18px; min-width: 0; }
.es-ev-t { font-size: 14px; font-weight: 500; line-height: 1.35; color: var(--text); }
.es-ev-s { font-size: 12px; color: var(--text2); margin-top: 2px; }
.es-pinned { padding: 12px 16px 30px; background: var(--bg); border-top: 1px solid var(--border); display: flex; gap: 10px; z-index: 10; }
.es-pinned .es-big { flex: 1; }
.es-pinned .es-sq { flex: 0 0 50px; width: 50px; height: 50px; display: flex; align-items: center; justify-content: center; border-radius: 12px; border: 1px solid var(--border2); background: var(--bg); color: var(--text); box-shadow: var(--shadow-xs); cursor: pointer; }
.es-pinned .es-sq svg { width: 19px; height: 19px; }
.es-pinned .es-sq:active { background: var(--bg2); }

/* Desktop: detail and success screens sit centred in the content column. */
@media (min-width: 769px) {
  .es-detail-wrap { flex: 1; min-height: 0; display: flex; justify-content: center; padding: 18px 22px 0; }
  .es-detail-wrap > .es-detail-col { width: 100%; max-width: 760px; display: flex; flex-direction: column; min-height: 0; background: var(--bg2); }
  .es-detail-wrap .es-pinned { padding: 12px 0 16px; background: var(--bg2); border-top: 1px solid var(--border); }
  .es-detail-wrap .es-pinned .es-big, .es-detail-wrap .es-pinned .es-sq { height: 42px; }
  .es-detail-wrap .es-pinned .es-sq { flex-basis: 42px; width: 42px; }
  .es-detail-wrap .es-tabbody, .es-detail-wrap .es-tl { padding-bottom: 24px; }
  .es-detail-wrap .es-detail-head { padding: 6px 0 16px; }
  .es-detail-wrap .es-detail-head .es-dhead-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
  .es-m-only { display: none !important; }
}

/* ── Toast (design: dark pill, bottom-centre, 1.9s) ───────────────── */
.es-toast { position: fixed; left: 50%; bottom: 28px; z-index: 5000; transform: translateX(-50%) translateY(8px); opacity: 0; pointer-events: none; transition: opacity .18s ease, transform .22s cubic-bezier(.32, .72, 0, 1); background: var(--es-popover); color: #fff; font-size: 13px; padding: 9px 16px; border-radius: 999px; box-shadow: var(--shadow-lg); white-space: nowrap; max-width: calc(100vw - 32px); overflow: hidden; text-overflow: ellipsis; font-family: inherit; }
.es-toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Bottom sheets (mobile action sheet + send confirm) ───────────── */
.es-scrim { position: fixed; inset: 0; z-index: 3100; background: var(--es-scrim); display: flex; flex-direction: column; justify-content: flex-end; opacity: 0; transition: opacity .18s ease; }
.es-scrim.on { opacity: 1; }
.es-sheet { background: var(--bg); border-radius: 22px 22px 0 0; padding: 8px 14px calc(34px + var(--safe-bottom, 0px)); box-shadow: 0 -10px 40px rgba(10, 20, 60, 0.25); transform: translateY(24px); transition: transform .26s cubic-bezier(.32, .72, 0, 1); }
.es-scrim.on .es-sheet { transform: none; }
.es-handlebar { width: 38px; height: 4px; border-radius: 2px; background: var(--border2); margin: 0 auto 12px; }
.es-sheet-title { padding: 0 6px 10px; font-size: 14px; font-weight: 500; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: var(--text); }
.es-sheet-item { height: 52px; display: flex; align-items: center; gap: 14px; padding: 0 8px; border-radius: 12px; font: inherit; font-size: 15px; color: var(--text); border: 0; background: none; width: 100%; text-align: left; cursor: pointer; }
.es-sheet-item:active { background: var(--es-hover); }
.es-sheet-item svg { width: 18px; height: 18px; color: var(--text2); }
.es-sheet-item.danger, .es-sheet-item.danger svg { color: var(--danger); }
.es-sheet-item.danger:active { background: var(--danger-soft); }
.es-sheet-sep { height: 1px; background: var(--border); margin: 6px; }
.es-sheet-confirm { padding: 6px; }
.es-sheet-confirm p { font-size: 14px; line-height: 1.5; color: var(--text); margin: 0; }
.es-sheet-row { display: flex; gap: 10px; margin-top: 16px; }
.es-sheet-row > button { flex: 1; height: 48px; display: flex; align-items: center; justify-content: center; gap: 8px; border-radius: 10px; border: 1px solid var(--border2); font: inherit; font-size: 14px; font-weight: 500; background: var(--bg); color: var(--text); cursor: pointer; }
.es-sheet-row > button.void { background: var(--status-denied-bg); border-color: var(--status-denied-line); color: var(--status-denied-ink); }
.es-sheet-row > button.send { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: var(--shadow-sm); height: 50px; border-radius: 12px; font-size: 15px; }
.es-sheet-row > button.send svg { width: 16px; height: 16px; }
.es-sheet.confirm { padding: 8px 18px calc(34px + var(--safe-bottom, 0px)); }
.es-sheet.confirm .es-handlebar { margin-bottom: 16px; }
.es-sheet.confirm h3 { font-size: 18px; font-weight: 500; letter-spacing: -0.01em; margin: 0; color: var(--text); }
.es-sheet.confirm p { font-size: 14px; line-height: 1.5; color: var(--text2); margin: 6px 0 0; }
.es-sheet.confirm .es-sheet-row { margin-top: 20px; }
.es-sheet.confirm .es-sheet-row > button { height: 50px; border-radius: 12px; font-size: 15px; }

/* ═════════════════════════════ Mobile ═════════════════════════════ */
@media (max-width: 768px) {
  #page-esign .es-topbar { display: none !important; }
  /* The page scrolls with the document on phones (as every other page does),
     so the tab row can stick under the app header. */
  #page-esign { min-height: 0; overflow: visible !important; }
  .es-d-only { display: none !important; }

  /* List screens scroll with the page under the app's own header + tab bar. */
  .es-mtabs { flex-shrink: 0; display: flex; background: var(--bg2); border-bottom: 1px solid var(--border); position: sticky; top: calc(46px + var(--safe-top, 0px)); z-index: 6; }
  .es-mtabs button { flex: 1 1 0; min-width: 0; text-align: center; font: inherit; font-size: 15px; color: var(--text2); padding: 12px 2px 11px; margin-bottom: -1px; border: 0; border-bottom: 2px solid transparent; background: none; cursor: pointer; }
  .es-mtabs button.on { color: var(--text); font-weight: 500; border-bottom-color: var(--navy); }
  .es-mlist { padding: 20px 14px 32px; display: flex; flex-direction: column; gap: 12px; }
  .es-msearch { position: relative; flex-shrink: 0; }
  .es-msearch > svg { position: absolute; left: 14px; top: 13px; width: 18px; height: 18px; color: var(--text2); pointer-events: none; }
  .es-msearch input { width: 100%; box-sizing: border-box; height: 44px; padding: 0 40px 0 42px; font: inherit; font-size: 16px; color: var(--text); background: var(--bg); border: 1px solid var(--border2); border-radius: 12px; outline: none; }
  .es-msearch input:focus { border-color: var(--accent); box-shadow: var(--es-ring); }
  .es-msearch .clear { position: absolute; right: 0; top: 0; width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; color: var(--text2); border: 0; background: none; }
  .es-msearch .clear svg { width: 16px; height: 16px; }
  .es-mupload { display: flex; align-items: center; justify-content: center; gap: 9px; height: 44px; flex-shrink: 0; border: 1.5px dashed var(--border2); border-radius: 12px; font: inherit; font-size: 13px; color: var(--text2); box-sizing: border-box; background: none; width: 100%; cursor: pointer; }
  .es-mupload:active { background: rgba(79, 139, 232, 0.08); border-color: var(--accent); }
  .es-mupload svg { width: 16px; height: 16px; }
  .es-mfilters { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; flex-shrink: 0; }
  /* Same look as the Listings chips: 32px, soft glass, pale blue when selected. */
  .es-mfilters button { height: 32px; padding: 0 6px; display: flex; align-items: center; justify-content: center; border-radius: 16px; font: inherit; font-size: 14px; font-weight: 600; box-sizing: border-box; white-space: nowrap; background: var(--glass-fill); color: var(--text2); border: none; box-shadow: var(--glass-edge); cursor: pointer; }
  .es-mfilters button.on { background: var(--accent-soft); color: #1d4ed8; }
  .es-mcard { flex-shrink: 0; background: var(--bg); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-xs); padding: 16px 16px 14px; display: flex; flex-direction: column; gap: 12px; cursor: pointer; text-align: left; font: inherit; color: inherit; width: 100%; box-sizing: border-box; }
  .es-mcard:active { transform: scale(0.985); background: var(--bg2); box-shadow: none; transition-duration: .08s; }
  .es-mcard-top { display: flex; align-items: flex-start; gap: 8px; }
  .es-mcard-title { flex: 1; min-width: 0; font-size: 15px; font-weight: 500; line-height: 1.3; letter-spacing: -0.012em; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: var(--text); }
  .es-mcard-kebab { flex: 0 0 44px; width: 44px; height: 44px; margin: -12px -12px -10px 0; display: flex; align-items: center; justify-content: center; color: var(--text2); border-radius: 12px; border: 0; background: none; }
  .es-mcard-kebab:active { background: var(--bg3); }
  .es-mcard-kebab svg { width: 18px; height: 18px; }
  .es-mcard-row { display: flex; align-items: center; gap: 8px; }
  .es-mcard-pages { font-size: 12px; letter-spacing: 0.01em; color: var(--text2); font-variant-numeric: tabular-nums; white-space: nowrap; }
  .es-mcard-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 12px; border-top: 1px solid var(--border); }
  .es-mcard-foot .who { display: flex; align-items: center; gap: 9px; min-width: 0; }
  .es-mcard-foot .es-av { flex: 0 0 26px; width: 26px; height: 26px; border-radius: 8px; font-size: 10px; letter-spacing: 0.02em; }
  .es-mcard-foot .es-av + .es-av { margin-left: -7px; }
  .es-mcard-foot .cnt { font-size: 13px; color: var(--text); white-space: nowrap; font-variant-numeric: tabular-nums; }
  .es-mcard-foot .when { font-size: 12px; letter-spacing: 0.01em; color: var(--text2); white-space: nowrap; font-variant-numeric: tabular-nums; }
  .es-mcard-link { display: flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 500; color: var(--es-amber); margin-top: -2px; }
  .es-mcard-link.linked { color: var(--es-success); }
  .es-mcard-link svg { width: 12px; height: 12px; }
  .es-mempty { text-align: center; padding: 40px 20px; font-size: 13px; color: var(--text2); }

  /* Templates empty: the button sits at the exact centre of the screen. */
  .es-mtpl-empty { position: fixed; left: 0; right: 0; top: 0; bottom: 0; pointer-events: none; z-index: 1; }
  .es-mtpl-empty .blk { position: absolute; left: 0; right: 0; bottom: calc(50% + 47px); display: flex; flex-direction: column; align-items: center; text-align: center; padding: 0 32px; }
  .es-mtpl-empty .blk > svg { width: 34px; height: 34px; color: var(--text3); opacity: 0.5; }
  .es-mtpl-empty .t { margin-top: 12px; font-size: 16px; font-weight: 500; white-space: nowrap; color: var(--text); }
  .es-mtpl-empty .s { margin-top: 6px; font-size: 13px; line-height: 1.5; color: var(--text2); max-width: 290px; }
  .es-navy-btn { height: 46px; padding: 0 20px; display: flex; align-items: center; justify-content: center; gap: 8px; border-radius: 10px; background: var(--navy); color: #fff; font: inherit; font-size: 14px; font-weight: 500; white-space: nowrap; box-shadow: var(--shadow-sm); border: 0; cursor: pointer; }
  .es-navy-btn svg { width: 16px; height: 16px; }
  .es-mtpl-empty .es-navy-btn { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); pointer-events: auto; }
  .es-mtpl-list { padding: 16px 14px 32px; display: flex; flex-direction: column; gap: 12px; }
  .es-tpl-card { cursor: pointer; }
  .es-tpl-card .es-btn-line { flex: 0 0 auto; background: var(--navy); border-color: var(--navy); color: #fff; box-shadow: var(--shadow-sm); font-weight: 600; }
  [data-theme="dark"] .es-tpl-card .es-btn-line, [data-theme="dark"] .es-navy-btn { background: var(--accent); border-color: var(--accent); color: #0b1018; }

  /* The app gives every button on a phone a 44px floor; these are drawn
     smaller by design (chips 32, filters 34, field toolbar 28) and sit in
     rows whose own height is the tap target. */
  #page-esign .es-ftb button, #page-esign .es-chip, #page-esign .es-mfilters button,
  #page-esign .es-tag, #page-esign .es-rcount, #page-esign .es-grip { min-height: 0; }
  /* ...and caps everything at its parent's width; the field toolbar sits above
     a field that can be narrower than it. */
  #page-esign .es-ftb { max-width: none; }

  /* Flow screens: a full panel under the app header; the tab bar is hidden. */
  body.es-flow .mtab-bar { display: none !important; }
  body.es-flow { padding-bottom: 0 !important; }
  .es-flow { position: fixed; top: calc(46px + var(--safe-top, 0px)); left: 0; right: 0; bottom: 0; z-index: 1000; background: var(--bg2); display: flex; flex-direction: column; }
  .es-ftitle { flex-shrink: 0; display: flex; align-items: center; gap: 4px; padding: 0 16px 0 6px; height: 50px; box-sizing: border-box; background: var(--bg2); }
  .es-ftitle.line { border-bottom: 1px solid var(--border); }
  .es-ftitle .back, .es-ftitle .more { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; color: var(--text); border: 0; background: none; flex-shrink: 0; }
  .es-ftitle .back svg { width: 24px; height: 24px; }
  .es-ftitle .more { margin-left: auto; margin-right: -10px; }
  .es-ftitle .more svg { width: 24px; height: 24px; stroke-width: 2.4; }
  .es-ftitle span { font-size: 18px; font-weight: 500; letter-spacing: -0.01em; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .es-fscroll { flex: 1; min-height: 0; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 16px; }
  .es-fbar { flex-shrink: 0; padding: 12px 16px calc(30px + var(--safe-bottom, 0px)); background: var(--bg); border-top: 1px solid var(--border); }
  .es-fbar .help { font-size: 12px; color: var(--text2); text-align: center; margin: -2px 0 10px; }
  .es-progress > div > span { margin-top: 7px; }
  .es-h1 { font-size: 24px; }
  .es-h1-sub { margin-top: 5px; }
  .es-card { border-radius: 14px; }
  .es-card-sec { padding: 16px; }
  .es-input { height: 46px; font-size: 16px; border-radius: 10px; }
  .es-label { margin-bottom: 8px; }
  .es-dz { height: 152px; gap: 6px; }
  .es-dz:active { transform: scale(0.985); border-color: var(--accent); background: rgba(79, 139, 232, 0.08); transition-duration: .08s; }
  .es-dz-icon { width: 46px; height: 46px; border-radius: 14px; box-shadow: 0 0 0 6px rgba(37, 99, 235, 0.06), var(--shadow-xs); }
  .es-dz-icon svg { width: 20px; height: 20px; }
  .es-dz-title { margin-top: 4px; }
  .es-file { padding: 12px; gap: 12px; }
  .es-thumb { flex-basis: 36px; width: 36px; height: 46px; }
  .es-file .es-x { width: 44px; height: 44px; margin-right: -8px; justify-content: center; align-items: center; color: var(--text2); }
  .es-file .es-x svg { width: 18px; height: 18px; }

  /* Recipients / roles (M5) */
  .es-mroles { display: flex; flex-direction: column; gap: 10px; }
  .es-mrole-wrap { position: relative; border-radius: 14px; }
  .es-mrole { display: flex; align-items: center; gap: 12px; background: var(--bg); border: 1px solid var(--border2); border-radius: 14px; padding: 12px 6px 12px 14px; box-shadow: var(--shadow-xs); }
  .es-mrole .es-grip { position: static; flex: 0 0 26px; width: 26px; height: 44px; margin: -12px 0 -12px -8px; border-radius: 0; }
  .es-mrole .es-grip svg { width: 16px; height: 16px; }
  .es-mrole .es-grip:active { color: var(--accent); }
  .es-badge { flex: 0 0 28px; width: 28px; height: 28px; border-radius: 50%; box-sizing: border-box; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; font-family: 'DM Mono', monospace; background: var(--bg); border: 2px solid var(--c); color: var(--text); }
  .es-badge.hide { visibility: hidden; }
  .es-mrole .main { flex: 1; min-width: 0; }
  .es-mrole input { width: 100%; box-sizing: border-box; padding: 2px 0; font: inherit; border: 0; border-bottom: 1px solid transparent; background: none; outline: none; color: var(--text); }
  .es-mrole input:focus { border-bottom-color: var(--accent); }
  .es-mrole input.nm { font-size: 16px; font-weight: 500; }
  .es-mrole input.em { font-size: 14px; color: var(--text2); }
  .es-mrole input.em.bad { border-bottom-color: var(--danger); }
  .es-mrole .role { font-size: 12px; color: var(--text2); margin-top: 2px; }
  .es-mrole .del { flex: 0 0 44px; width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; color: var(--text3); border: 0; background: none; }
  .es-mrole .del svg { width: 18px; height: 18px; }
  .es-madd { height: 48px; display: flex; align-items: center; justify-content: center; gap: 7px; border: 1.5px dashed var(--border2); border-radius: 14px; font: inherit; font-size: 14px; font-weight: 500; color: var(--text2); background: none; width: 100%; cursor: pointer; }
  .es-madd:active { border-color: var(--accent); background: rgba(37, 99, 235, 0.04); }
  .es-madd svg { width: 16px; height: 16px; }
  .es-morder { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 14px; padding: 14px; font: inherit; color: inherit; text-align: left; width: 100%; cursor: pointer; }
  .es-morder .t { font-size: 14px; font-weight: 500; }
  .es-morder .s { font-size: 12px; color: var(--text2); margin-top: 2px; }
  .es-morder .es-switch { flex: 0 0 44px; width: 44px; height: 26px; border-radius: 13px; }
  .es-morder .es-switch::after { top: 3px; left: 3px; width: 20px; height: 20px; }
  .es-morder .es-switch.on::after { left: 21px; }

  /* Place fields (M6) */
  .es-chips { flex-shrink: 0; display: flex; gap: 8px; overflow-x: auto; padding: 2px 16px 10px; scrollbar-width: none; }
  .es-chips::-webkit-scrollbar, .es-tray-row::-webkit-scrollbar { display: none; }
  .es-chip { flex: 0 0 auto; height: 32px; padding: 0 11px; display: flex; align-items: center; gap: 6px; border-radius: 16px; box-sizing: border-box; font: inherit; font-size: 12px; white-space: nowrap; background: var(--bg); color: var(--text); border: 1px solid var(--border2); cursor: pointer; }
  .es-chip.on { border: 1.5px solid var(--c); font-weight: 500; box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 30%, #fff); }
  .es-chip .dot { flex: 0 0 10px; width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
  .es-chip .nm { max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
  .es-chip .n { font-family: 'DM Mono', monospace; font-size: 11px; color: var(--text2); }
  .es-mcanvas { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 16px 16px; background: var(--bg3); }
  .es-mcanvas .es-pages { gap: 12px; }
  .es-mcanvas .es-page { box-shadow: var(--shadow-xs); }
  .es-mcanvas .es-field { border-width: 1px; border-radius: 3px; --tint: color-mix(in srgb, var(--fc) 14%, #fff); }
  .es-mcanvas .es-field.t-whiteout, .es-mcanvas .es-field.t-redact, .es-mcanvas .es-field.t-highlight { border-radius: 0; }
  .es-mcanvas .es-field.sel { box-shadow: 0 0 0 2px color-mix(in srgb, var(--fc) 45%, #fff); }
  .es-mcanvas .es-ftag { top: -7px; left: 3px; height: 11px; padding: 0 4px 0 3px; font-size: 6.5px; gap: 2px; transform: none; }
  .es-mcanvas .es-ftag::before { width: 4px; height: 4px; flex-basis: 4px; }
  .es-mcanvas .es-ftb { bottom: calc(100% + 6px); left: 0; transform: none; }
  .es-mcanvas .es-ftb-in { background: var(--es-popover); border: 0; border-radius: 8px; padding: 0; box-shadow: var(--shadow-lg); gap: 0; }
  .es-mcanvas .es-ftb-in::after { display: none; }
  .es-mcanvas .es-ftb button { width: 32px; height: 28px; color: #fff; border-radius: 8px; }
  .es-mcanvas .es-ftb button.del { color: #fca5a5; }
  .es-mcanvas .es-ftb .sep { background: rgba(255, 255, 255, 0.25); }
  .es-mcanvas .es-ftb input { width: 150px; height: 24px; margin: 2px; font-size: 16px; transform: scale(0.75); transform-origin: 0 50%; width: 200px; margin-right: -46px; }
  .es-mcanvas .es-handle { right: -4px; bottom: -4px; border-radius: 50%; }
  .es-tray { flex-shrink: 0; background: var(--bg); border-top: 1px solid var(--border); box-shadow: 0 -6px 18px rgba(20, 30, 60, 0.05); padding: 14px 0 calc(28px + var(--safe-bottom, 0px)); position: relative; z-index: 2; }
  .es-tray-row { display: flex; gap: 6px; overflow-x: auto; padding: 0 16px; scroll-padding: 0 16px; scrollbar-width: none; }
  .es-tool { flex: 0 0 66px; height: 52px; box-sizing: border-box; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; border-radius: 10px; background: var(--bg); border: 1px solid var(--border2); color: var(--text); font: inherit; cursor: pointer; padding: 0; }
  .es-tool svg { width: 18px; height: 18px; }
  .es-tool span { font-size: 10px; font-weight: 500; letter-spacing: -0.01em; white-space: nowrap; }
  .es-tool.on { background: rgba(37, 99, 235, 0.10); border: 1.5px solid rgba(37, 99, 235, 0.45); color: var(--es-sent-ink); }
  .es-tool-sep { flex: 0 0 1px; align-self: stretch; margin: 6px 2px; background: var(--border2); }
  .es-tray .go { padding: 14px 16px 0; }
  .es-tray .es-big { height: 48px; }

  /* Review (M7) */
  .es-rv-doc { display: flex; align-items: center; gap: 12px; padding: 14px; }
  .es-rv-doc .es-thumb { flex-basis: 36px; width: 36px; height: 46px; }
  .es-rv-name { font-size: 14px; font-weight: 500; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: var(--text); }
  .es-rv-meta { font-size: 12px; color: var(--text2); margin-top: 3px; }
  .es-rv-head { padding: 12px 14px; font-size: 12px; font-weight: 500; color: var(--text2); border-bottom: 1px solid var(--border); }
  .es-mchecks { display: flex; flex-direction: column; gap: 7px; }
  .es-mchecks .es-check { font-size: 13px; gap: 8px; }
  .es-mchecks .es-check-dot { width: 16px; height: 16px; flex-basis: 16px; background: var(--status-pending-bg); color: var(--es-amber); }
  .es-mchecks .es-check-dot svg { width: 10px; height: 10px; }
  .es-mchecks .es-check.ok .es-check-dot { background: rgba(21, 128, 61, 0.12); color: var(--es-success); }
  .es-msg textarea { width: 100%; box-sizing: border-box; padding: 12px; font: inherit; font-size: 16px; line-height: 1.4; color: var(--text); background: var(--bg); border: 1px solid var(--border2); border-radius: 10px; outline: none; resize: none; }
  .es-msg textarea:focus { border-color: var(--accent); box-shadow: var(--es-ring); }

  /* Detail (M8) */
  .es-pinned { position: absolute; left: 0; right: 0; bottom: 0; padding-bottom: calc(30px + var(--safe-bottom, 0px)); }
  .es-toast { bottom: calc(128px + var(--safe-bottom, 0px)); }
  body.es-flow .es-toast { bottom: calc(110px + var(--safe-bottom, 0px)); }
}

@media (prefers-reduced-motion: reduce) {
  #page-esign *, .es-portal, .es-portal *, .es-toast, .es-scrim, .es-sheet { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* Signing steps: "Sign together with above" puts a recipient in the step above (one group). */
.es-with { display: flex; align-items: center; gap: 6px; width: 100%; margin-top: 8px; padding: 6px 8px; border: 1px dashed var(--border2); border-radius: 8px; background: transparent; color: var(--text2); font: inherit; font-size: 12px; cursor: pointer; text-align: left; }
.es-with svg { width: 14px; height: 14px; flex: 0 0 14px; }
.es-with > span:not(.es-switch) { flex: 1; min-width: 0; }
.es-with.on { border-style: solid; border-color: color-mix(in srgb, var(--accent) 35%, transparent); color: var(--text); background: color-mix(in srgb, var(--accent) 6%, transparent); }
.es-with .es-switch.sm { flex: 0 0 28px; width: 28px; height: 16px; border-radius: 8px; }
.es-with .es-switch.sm::after { width: 12px; height: 12px; }
.es-with .es-switch.sm.on::after { left: 14px; }
.es-with.m { margin: 6px 0 0; min-height: 44px; font-size: 14px; }
.es-rrow.together .es-rail-n { background: transparent; color: var(--text3); }
/* A denied signer (they declined to sign). */
.es-pill.s-denied { background: rgba(185, 28, 28, 0.10); color: #b91c1c; border-color: rgba(185, 28, 28, 0.25); }
.es-sigpop-st.denied { color: #b91c1c; }
/* Radio: which pick-one group the selected button belongs to. */
.es-ftb-note { font-size: 11px; color: var(--text2); white-space: nowrap; padding: 0 4px; }

/* e-Sign status pill — still used by the inbox e-Sign panel. */
  .esign-status-pill {
    display:inline-block; padding:3px 10px; border-radius:99px;
    font-size:11px; text-transform:uppercase; letter-spacing:0.5px; font-weight:500;
    background:var(--bg3); color:var(--text2); border:1px solid var(--border2);
  }
  .esign-status-pill[data-status="draft"]              { background:rgba(168,162,158,0.10); color:#a8a29e; border-color:rgba(168,162,158,0.20); }
  .esign-status-pill[data-status="sent"]               { background:rgba(79,139,232,0.10);  color:#4f8be8; border-color:rgba(79,139,232,0.30); }
  .esign-status-pill[data-status="partially_signed"]   { background:rgba(201,168,99,0.10);  color:#c9a863; border-color:rgba(201,168,99,0.30); }
  .esign-status-pill[data-status="completed"]          { background:rgba(21,128,61,0.10);   color:#15803d; border-color:rgba(21,128,61,0.30); }
  .esign-status-pill[data-status="void"]               { background:rgba(220,38,38,0.10);   color:#dc2626; border-color:rgba(220,38,38,0.30); }

/* Templates (desktop): larger cards in a grid. */
.es-tpl-gridwrap { max-width: 1120px; gap: 6px; }
.es-tpl-strip { padding: 0 !important; margin: 0 0 14px; }
.es-tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(268px, 1fr)); gap: 18px; align-content: start; padding: 4px 2px 24px; }
.es-tpl-tile { display: flex; flex-direction: column; background: var(--bg); border: 1px solid var(--border); border-radius: 18px; overflow: hidden; cursor: pointer; box-shadow: 0 1px 2px rgba(24, 32, 56, 0.04), 0 8px 24px -12px rgba(24, 32, 56, 0.12); transition: transform .22s cubic-bezier(.32, .72, 0, 1), box-shadow .22s ease, border-color .22s ease; }
.es-tpl-tile:hover { transform: translateY(-3px); border-color: rgba(37, 99, 235, 0.30); box-shadow: 0 2px 4px rgba(24, 32, 56, 0.05), 0 18px 36px -14px rgba(37, 99, 235, 0.28); }
.es-tpl-prev { position: relative; height: 128px; display: flex; align-items: flex-end; justify-content: center; padding-top: 18px; background: linear-gradient(180deg, #eef2fc 0%, #e3e9f9 100%); border-bottom: 1px solid var(--border); overflow: hidden; }
.es-tpl-sheet { width: 112px; height: 100%; background: #fff; border-radius: 8px 8px 0 0; box-shadow: 0 -2px 14px rgba(37, 99, 235, 0.14), 0 0 0 1px rgba(24, 32, 56, 0.06); padding: 14px 12px 0; display: flex; flex-direction: column; gap: 7px; transition: transform .25s cubic-bezier(.32, .72, 0, 1); }
.es-tpl-tile:hover .es-tpl-sheet { transform: translateY(-4px); }
.es-tpl-sheet u { display: block; height: 4px; border-radius: 2px; background: #e4e7ee; }
.es-tpl-sheet u.s { width: 62%; }
.es-tpl-marks { margin-top: auto; padding-bottom: 12px; display: flex; gap: 6px; }
.es-tpl-marks b { flex: 1; height: 12px; border-radius: 4px; opacity: .9; }
.es-tpl-pill { position: absolute; top: 12px; right: 12px; font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: rgba(255, 255, 255, 0.85); color: var(--text2); box-shadow: 0 0 0 1px rgba(24, 32, 56, 0.06); }
/* Dark mode: the preview band sits in the card's own dark tone; the page itself stays paper-white. */
[data-theme="dark"] .es-tpl-prev { background: linear-gradient(180deg, var(--bg3) 0%, var(--bg2) 100%); }
[data-theme="dark"] .es-tpl-pill { background: rgba(16, 25, 41, 0.72); color: var(--text2); box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.10); }
.es-tpl-body { padding: 16px 18px 6px; display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; }
.es-tpl-tile .es-tpl-name { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.es-tpl-tile .es-tpl-meta { font-size: 12.5px; }
.es-tpl-roles { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.es-tpl-role { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 3px 10px 3px 8px; background: var(--bg2); border: 1px solid var(--border); border-radius: 999px; color: var(--text2); }
.es-tpl-role i { width: 7px; height: 7px; border-radius: 50%; background: var(--rc); }
.es-tpl-role.more { padding-left: 10px; }
.es-tpl-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px 14px 18px; }
.es-tpl-upd { font-size: 12px; color: var(--text3); }
.es-tpl-use { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px; border: 0; border-radius: 10px; background: var(--navy); color: #fff; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; transition: background .15s, transform .15s; }
[data-theme="dark"] .es-tpl-use { background: var(--accent); color: #0b1018; }
.es-tpl-use svg { width: 14px; height: 14px; transition: transform .2s; }
.es-tpl-tile:hover .es-tpl-use svg { transform: translateX(2px); }
.es-tpl-none { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 56px 16px; text-align: center; color: var(--text2); }
.es-tpl-none svg { width: 28px; height: 28px; opacity: .6; }
.es-tpl-none-t { font-size: 15px; font-weight: 600; color: var(--text); }
.es-tpl-none-s { font-size: 13px; max-width: 320px; margin-bottom: 6px; }

/* Templates (desktop): compact tiles, four across. */
.es-tpl-grid { grid-template-columns: repeat(auto-fill, minmax(214px, 1fr)); gap: 14px; }
.es-tpl-tile { border-radius: 14px; }
.es-tpl-prev { height: 84px; padding-top: 12px; }
.es-tpl-sheet { width: 74px; padding: 9px 8px 0; gap: 5px; border-radius: 6px 6px 0 0; }
.es-tpl-sheet u { height: 3px; }
.es-tpl-marks { padding-bottom: 8px; gap: 4px; }
.es-tpl-marks b { height: 8px; border-radius: 3px; }
.es-tpl-pill { top: 8px; right: 8px; font-size: 10px; padding: 2px 7px; }
.es-tpl-body { padding: 12px 14px 4px; }
.es-tpl-tile .es-tpl-name { font-size: 13.5px; }
.es-tpl-tile .es-tpl-meta { font-size: 11.5px; }
.es-tpl-roles { gap: 4px; margin-top: 8px; }
.es-tpl-role { font-size: 11px; padding: 2px 8px 2px 6px; gap: 5px; }
.es-tpl-role i { width: 6px; height: 6px; }
.es-tpl-foot { padding: 8px 10px 11px 14px; }
.es-tpl-upd { font-size: 11px; }
.es-tpl-use { height: 28px; padding: 0 11px; font-size: 12px; border-radius: 8px; }
.es-tpl-use svg { width: 12px; height: 12px; }
