:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1c2230;
  --muted: #667085;
  --line: #e2e5ea;
  --accent: #1d4ed8;
  --accent-dark: #1e3a8a;
  --danger: #b42318;
  --ok: #067647;
  --warn: #b54708;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; overflow-wrap: break-word; }
h1 { font-size: 1.5rem; margin: 0 0 0.5rem; }
h2 { font-size: 1.15rem; margin: 0 0 0.75rem; }
h3 { font-size: 0.95rem; margin: 0 0 0.6rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.loading { padding: 3rem; text-align: center; color: var(--muted); }
.pre { white-space: pre-wrap; }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.topbar, .sign-top {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.7rem 1.25rem; background: #fff; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 0.5rem; font-weight: 700; font-size: 1.1rem; color: var(--text); text-decoration: none; }
.brand-mark { display: inline-grid; place-items: center; width: 1.8rem; height: 1.8rem; border-radius: 7px; background: var(--accent); color: #fff; font-size: 1rem; }
.brand-sub { font-weight: 400; color: var(--muted); font-size: 0.9rem; margin-left: 0.25rem; }
.topbar-right { display: flex; align-items: center; gap: 0.75rem; }
.who { color: var(--muted); font-size: 0.9rem; }
.sign-doc { display: flex; flex-direction: column; align-items: flex-end; text-align: right; min-width: 0; }
.sign-doc strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 55vw; }

.expiry-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding: 0.65rem 1.25rem; background: #fffaeb; border-bottom: 1px solid #fedf89; color: #93370d; font-size: 0.92rem;
}
.expiry-banner.urgent { background: #fef3f2; border-color: #fecdca; color: #912018; }
.list-foot { margin-top: 1rem; text-align: right; }
.check-list { list-style: none; padding: 0; margin: 0; }
.check-list li { padding: 0.6rem 0; border-bottom: 1px dashed var(--line); }
.check-list li.ok strong { color: var(--ok); }
.check-list li.bad strong { color: var(--danger); }
.check-list li.skip { color: var(--muted); }
.renew-help ol { padding-left: 1.3rem; }
.renew-help li { margin-bottom: 0.6rem; line-height: 1.45; }
code { background: #f2f4f7; padding: 0.05em 0.35em; border-radius: 4px; font-size: 0.9em; }

/* ---------- layout ---------- */
.content { max-width: 1000px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }
.content.wide { max-width: none; padding: 0; }
.content.narrow { max-width: 560px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem 1.5rem; margin-bottom: 1.25rem; }
.card { overflow-x: auto; }
.card.center { text-align: center; padding: 2.5rem 2rem; margin-top: 2rem; }
.card.center .btn { margin-top: 0.5rem; }
.card.empty { text-align: center; padding: 3rem 2rem; }
.card.error { border-color: #fecdca; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.button-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0 0 1.25rem; }
.back { display: inline-block; margin-bottom: 0.75rem; text-decoration: none; }

/* ---------- forms ---------- */
label { display: block; font-size: 0.85rem; font-weight: 600; margin: 0.75rem 0 0.3rem; }
input, textarea, select {
  width: 100%; font: inherit; font-size: 0.95rem; color: var(--text);
  padding: 0.5rem 0.65rem; border: 1px solid #cfd4dc; border-radius: 7px; background: #fff;
}
input:focus, textarea:focus, select:focus { outline: 2px solid #c7d7fe; border-color: var(--accent); }
textarea { resize: vertical; }
label.check { display: flex; gap: 0.5rem; align-items: flex-start; font-weight: 400; font-size: 0.9rem; cursor: pointer; }
label.check input { width: auto; margin-top: 0.2rem; }
.form-error { color: var(--danger); min-height: 1.2em; font-size: 0.9rem; }
.login { max-width: 420px; margin: 3rem auto; }
.login .btn { margin-top: 1rem; }
.login .center { text-align: center; margin-top: 0.4rem; }
.ms-signin { gap: 0.6rem; padding: 0.7rem 1rem; font-size: 1rem; }
.ms-logo { display: inline-grid; grid-template-columns: 8px 8px; gap: 2px; }
.ms-logo span { width: 8px; height: 8px; display: block; }
.ms-logo span:nth-child(1) { background: #f25022; }
.ms-logo span:nth-child(2) { background: #7fba00; }
.ms-logo span:nth-child(3) { background: #00a4ef; }
.ms-logo span:nth-child(4) { background: #ffb900; }
.or { display: flex; align-items: center; gap: 0.6rem; color: var(--muted); font-size: 0.85rem; margin: 1.4rem 0 0.3rem; }
.or::before, .or::after { content: ""; flex: 1; border-top: 1px solid var(--line); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem;
  font: inherit; font-size: 0.92rem; font-weight: 600; line-height: 1.2;
  padding: 0.55rem 1rem; border-radius: 7px; border: 1px solid #cfd4dc;
  background: #fff; color: var(--text); cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: #f6f7f9; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); }
.btn.danger { background: #fff; border-color: #fda29b; color: var(--danger); }
.btn.danger:hover { background: #fef3f2; }
.btn.link { border: none; background: none; color: var(--accent); padding: 0.25rem 0.35rem; font-weight: 500; }
.btn.link:hover { text-decoration: underline; background: none; }
.btn.danger-text { color: var(--danger); }
.btn.small { font-size: 0.82rem; padding: 0.35rem 0.65rem; }
.btn.block { width: 100%; }
.icon-btn { border: none; background: none; cursor: pointer; color: var(--muted); font-size: 0.9rem; padding: 0.15rem 0.35rem; border-radius: 5px; }
.icon-btn:hover { background: #eef0f3; color: var(--text); }

/* ---------- badges & tables ---------- */
.badge { display: inline-block; font-size: 0.78rem; font-weight: 600; padding: 0.2rem 0.55rem; border-radius: 999px; background: #eef0f3; color: #344054; white-space: nowrap; }
.badge.s-sent, .badge.r-viewed { background: #fef0c7; color: #93370d; }
.badge.s-completed, .badge.r-signed { background: #dcfae6; color: #085d3a; }
.badge.s-declined, .badge.s-voided, .badge.r-declined { background: #fee4e2; color: #912018; }
.badge.r-pending { background: #eef0f3; color: #475467; }
.dot { display: inline-block; width: 0.55rem; height: 0.55rem; border-radius: 50%; background: #c0c5cf; margin-right: 0.45rem; }
.dot.r-viewed { background: #f79009; }
.dot.r-signed { background: #17b26a; }
.dot.r-declined { background: #f04438; }
.table { width: 100%; border-collapse: collapse; background: #fff; }
.table th { text-align: left; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--line); }
.table td { padding: 0.7rem 0.75rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table.docs { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.clickable { cursor: pointer; }
.clickable:hover td { background: #f9fafb; }
.doc-title { font-weight: 600; text-decoration: none; color: var(--text); }
.signer-line { font-size: 0.9rem; white-space: nowrap; }
.list-head { display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: 1rem; margin-bottom: 1rem; }
.tabs { display: flex; gap: 0.25rem; flex-wrap: wrap; }
.tab { font: inherit; font-size: 0.88rem; border: 1px solid transparent; background: none; padding: 0.35rem 0.7rem; border-radius: 7px; cursor: pointer; color: var(--muted); }
.tab.active { background: #fff; border-color: var(--line); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }
.count { font-size: 0.75rem; color: var(--muted); }

/* ---------- detail ---------- */
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.notice { padding: 0.75rem 1rem; border-radius: 8px; margin-bottom: 1rem; background: #eff4ff; border: 1px solid #c7d7fe; }
.notice.n-completed { background: #ecfdf3; border-color: #abefc6; }
.notice.n-declined, .notice.n-voided { background: #fef3f2; border-color: #fecdca; }
.history { list-style: none; padding: 0; margin: 0; }
.history li { padding: 0.45rem 0; border-bottom: 1px dashed var(--line); font-size: 0.9rem; }
.history .when { display: inline-block; min-width: 11rem; color: var(--muted); }

/* ---------- editor ---------- */
.editor { display: grid; grid-template-columns: 330px 1fr; height: calc(100vh - 57px); }
.sidebar { background: #fff; border-right: 1px solid var(--line); overflow-y: auto; }
.side-section { padding: 1rem 1.1rem; border-bottom: 1px solid var(--line); }
.side-section > label:first-of-type { margin-top: 0.25rem; }
.side-section.actions { position: sticky; bottom: 0; background: #fff; border-top: 1px solid var(--line); }
.side-section.actions .row-between { margin-top: 0.5rem; }
.recipient { border: 1px solid var(--line); border-left: 4px solid var(--c); border-radius: 8px; padding: 0.55rem 0.65rem; margin-bottom: 0.6rem; }
.recipient input { margin-top: 0.35rem; }
.recipient-top { display: flex; align-items: center; gap: 0.4rem; }
.swatch { width: 0.8rem; height: 0.8rem; border-radius: 3px; background: var(--c); }
.spacer { flex: 1; }
.palette > label { margin-top: 0; }
.palette-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem; margin-top: 0.6rem; }
.palette-btn {
  display: flex; align-items: center; gap: 0.45rem; font: inherit; font-size: 0.86rem; text-align: left;
  padding: 0.45rem 0.55rem; border: 1px solid var(--line); border-left: 3px solid var(--c);
  border-radius: 7px; background: #fff; cursor: pointer;
}
.palette-btn:hover { background: #f6f7f9; }
.palette-btn.active { background: color-mix(in srgb, var(--c) 14%, white); border-color: var(--c); font-weight: 600; }
.ficon { width: 1rem; text-align: center; font-size: 0.85rem; color: #475467; }
.ficon.f-signature::before { content: "✍"; }
.ficon.f-initials::before { content: "AB"; font-size: 0.65rem; font-weight: 700; }
.ficon.f-name::before { content: "👤"; font-size: 0.75rem; }
.ficon.f-email::before { content: "@"; font-weight: 700; }
.ficon.f-date::before { content: "📅"; font-size: 0.75rem; }
.ficon.f-text::before { content: "T"; font-weight: 700; }
.ficon.f-checkbox::before { content: "☑"; }
.ficon.f-firstname::before { content: "F"; font-weight: 700; }
.ficon.f-lastname::before { content: "L"; font-weight: 700; }
.ficon.f-number::before { content: "#"; font-weight: 700; }
.ficon.f-radio::before { content: "◉"; }
.ficon.f-dropdown::before { content: "▾"; font-weight: 700; }
.recipient.cc { border-left-style: dashed; background: #fafbfc; }
.kind-select { margin-top: 0.35rem; font-size: 0.82rem; }
.row-inline { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-top: 0.5rem; }
.row-inline label { margin: 0; display: flex; align-items: center; gap: 0.3rem; font-size: 0.85rem; }
input.num { width: 4.5rem; }
.editing .field.readonly { border-style: dotted; }

/* ---------- archive (documents signed in DocuSign) ---------- */
.archive-filters { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-bottom: 0.9rem; }
.archive-filters .search { flex: 1; min-width: 14rem; max-width: 28rem; }
.archive-filters select { width: auto; }
.table.archive td.nowrap { white-space: nowrap; }
.table.archive tfoot td { text-align: center; padding-top: 0.8rem; }

/* ---------- access codes and the e-signature disclosure ---------- */
.access-row { display: flex; gap: 0.4rem; align-items: center; margin-top: 0.4rem; }
.access-row input { margin-top: 0; flex: 1; min-width: 0; }
.access-form { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; margin-top: 1rem; }
.access-input { max-width: 16rem; text-align: center; font-size: 1.3rem; letter-spacing: 0.15em; text-transform: uppercase; }
.disclosure-details { margin: 0.6rem 0 0.8rem; }
.disclosure-details summary { cursor: pointer; color: var(--accent); font-size: 0.9rem; }
.disclosure { font-size: 0.88rem; line-height: 1.5; max-height: 22rem; overflow-y: auto; padding: 0.5rem 0.75rem; border: 1px solid var(--line); border-radius: 8px; background: #fafbfc; margin-top: 0.5rem; }
.disclosure h3 { font-size: 0.92rem; margin: 0.8rem 0 0.2rem; }
.disclosure p { margin: 0 0 0.4rem; }
.modal .disclosure { max-height: 60vh; }

/* ---------- top navigation, templates, import (stage 4) ---------- */
.topnav { display: flex; gap: 0.25rem; margin-right: auto; margin-left: 1.25rem; }
.topnav a { padding: 0.4rem 0.75rem; border-radius: 7px; color: var(--muted); text-decoration: none; font-weight: 600; font-size: 0.95rem; }
.topnav a:hover { background: #f2f4f7; color: var(--text); }
.topnav a.active { background: #eef4ff; color: var(--accent); }
.tpl-layout { display: grid; grid-template-columns: 240px 1fr; gap: 1.25rem; align-items: start; }
.folder-list { display: flex; flex-direction: column; gap: 0.15rem; position: sticky; top: 4.5rem; }
.folder-heading { font-size: 0.75rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin: 0.8rem 0 0.25rem 0.5rem; }
.folder-btn {
  display: flex; align-items: center; gap: 0.5rem; width: 100%; padding: 0.45rem 0.6rem; border: none; border-radius: 7px;
  background: transparent; font: inherit; font-size: 0.92rem; text-align: left; cursor: pointer; color: var(--text);
}
.folder-btn:hover { background: #f2f4f7; }
.folder-btn.active { background: #eef4ff; color: var(--accent); font-weight: 600; }
a.folder-btn { text-decoration: none; box-sizing: border-box; }
.folder-btn.trash-link { margin-top: 0.8rem; border-top: 1px solid var(--line); border-radius: 0 0 7px 7px; color: var(--muted); }
.folder-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-icon { width: 1.1rem; text-align: center; }
.tpl-main .search { width: 100%; max-width: 420px; margin-bottom: 0.75rem; }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions .btn { margin-left: 0.3rem; }
.badge.r-cc { background: #f4ebff; color: #53389e; }
.import .steps { margin: 0 0 1rem 1.1rem; padding: 0; line-height: 1.6; }
.file-btn { position: relative; overflow: hidden; display: inline-block; cursor: pointer; }
.file-btn input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.import-status { margin-top: 0.75rem; color: var(--muted); }
.import-table td { vertical-align: top; }
.import-table tr.muted td { color: var(--muted); }
.import td input:not([type="checkbox"]) { width: 100%; }
.ok-text { color: #067647; }
@media (max-width: 800px) {
  .tpl-layout { grid-template-columns: 1fr; }
  .folder-list { position: static; flex-direction: row; flex-wrap: wrap; }
  .folder-btn { width: auto; }
  .topnav { margin-left: 0.5rem; }
}
.props { margin-top: 1rem; padding-top: 0.75rem; border-top: 1px dashed var(--line); }
.props .btn { margin-top: 0.9rem; }
.props-title { display: flex; gap: 0.4rem; align-items: center; font-weight: 600; }
.viewer { overflow-y: auto; padding: 1.25rem; position: relative; }
.place-hint {
  position: sticky; top: 0; z-index: 5; margin: 0 auto 0.75rem; max-width: 900px;
  background: var(--accent); color: #fff; padding: 0.55rem 0.9rem; border-radius: 8px; font-size: 0.9rem;
}

/* ---------- pages & fields ---------- */
.pages { display: flex; flex-direction: column; align-items: center; gap: 0.35rem; }
.page { position: relative; width: 100%; max-width: 900px; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18); }
.page-canvas { display: block; width: 100%; height: 100%; }
.field-layer { position: absolute; inset: 0; }
.page-label { font-size: 0.75rem; color: var(--muted); margin-bottom: 0.9rem; }
.page-label.with-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 0.2rem 1rem; width: 100%; max-width: 900px; }
.page-label.with-tools .btn.link { padding: 0.15rem 0; font-size: 0.75rem; }
.add-pages input[type='file'] { display: block; margin: 0.6rem 0 0.3rem; }
.file-list { margin: 0.2rem 0 0.6rem; padding-left: 1.2rem; }
.pages.placing .page { cursor: crosshair; }
.field {
  position: absolute; display: flex; align-items: center; overflow: hidden;
  font-size: max(7px, calc(var(--pt, 1px) * 8.5)); line-height: 1.1; color: #101828;
  border-radius: 3px; user-select: none;
}
.editing .field {
  background: color-mix(in srgb, var(--c) 20%, transparent);
  border: 1.5px solid var(--c); cursor: move; padding: 0 0.25em; touch-action: none;
}
.editing .field.selected { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--c); z-index: 2; }
.editing .field.t-checkbox { justify-content: center; padding: 0; }
.field-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
.editing .field.req:not(.t-name):not(.t-email):not(.t-date) .field-text::after { content: " *"; color: var(--danger); }
.handle {
  position: absolute; right: -1px; bottom: -1px; width: 9px; height: 9px;
  background: var(--c); cursor: nwse-resize; border-radius: 2px 0 2px 0;
}
.editing .field:not(.selected) .handle { opacity: 0; }
.editing .field:hover .handle { opacity: 1; }

/* signer view */
.sign-main { max-width: 960px; padding-bottom: 6rem; }
.note { background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 8px; padding: 0.8rem 1rem; margin-bottom: 1rem; }
.consent { border-color: #c7d7fe; }
.consent .btn { margin-top: 0.9rem; }
.instructions { margin: 0 0 0.75rem; }
#app.locked .pages { opacity: 0.5; pointer-events: none; filter: grayscale(0.3); }
.signing .field.mine { background: #fff4c2; border: 1.5px dashed #d99a06; cursor: pointer; justify-content: center; }
.signing .field.mine:hover { background: #ffeb99; }
.signing .field.mine.req:not(.done):not(.auto)::after { content: "*"; position: absolute; top: -1px; right: 2px; color: var(--danger); font-weight: 700; }
.signing .field.mine.done { background: rgba(23, 178, 106, 0.08); border: 1px dashed #47cd89; }
.signing .field.mine.auto { background: rgba(29, 78, 216, 0.06); border: 1px dashed #84adff; cursor: default; justify-content: flex-start; padding: 0 0.25em; }
.signing .field.mine.t-text { background: #fff4c2; padding: 0; }
.signing .field.mine.t-text.done { background: rgba(23, 178, 106, 0.08); }
.field-input {
  width: 100%; height: 100%; border: none; background: transparent; padding: 0 0.3em;
  font-size: max(10px, calc(var(--pt, 1px) * 9.5)); border-radius: 0;
}
.field-input:focus { outline: 2px solid var(--accent); }
.field img { max-width: 100%; max-height: 100%; pointer-events: none; }
.field.other { justify-content: flex-start; }
.field.other.t-checkbox, .signing .field.t-checkbox { justify-content: center; }
.check-mark { font-weight: 700; color: #0b1f4d; font-size: max(9px, calc(var(--pt, 1px) * 11)); }
.field-value { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #0b1f4d; }
/* stage 4 field kinds */
.field.sized, .field.sized .field-input { font-size: max(6px, calc(var(--pt, 1px) * var(--fs, 9))); }
.field.sized .field-input { padding: 0 0.15em; }
.field.multi { align-items: flex-start; }
.field.multi .field-value { white-space: pre-wrap; }
textarea.field-input { resize: none; line-height: 1.15; padding-top: 0.1em; }
select.field-input { padding: 0; background: transparent; cursor: pointer; }
.signing .field.mine.t-number, .signing .field.mine.t-dropdown { background: #fff4c2; padding: 0; }
.signing .field.mine.t-number.done, .signing .field.mine.t-dropdown.done { background: rgba(23, 178, 106, 0.08); }
.signing .field.mine.invalid { border-color: var(--danger); background: #fde8e8; }
.signing .field.mine.readonly { background: transparent; border-color: transparent; }
.field.t-radio { border-radius: 50%; justify-content: center; padding: 0; }
.editing .field.t-radio, .editing .field.t-checkbox { padding: 0; }
.signing .field.t-radio, .field.other.t-radio { justify-content: center; }
.radio-dot { width: 55%; height: 55%; border-radius: 50%; background: #0b1f4d; }
.editing .field.req:is(.t-firstname, .t-lastname) .field-text::after { content: none; }
.field.flash { animation: flash 1.2s ease-out; }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 4px rgba(217, 119, 6, 0.65); } 100% { box-shadow: 0 0 0 0 rgba(217, 119, 6, 0); } }
.signbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.75rem 1.25rem; background: #fff; border-top: 1px solid var(--line); box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05);
}
.signbar-buttons { display: flex; gap: 0.5rem; }
.progress-text { font-size: 0.9rem; color: var(--muted); }
.signbar .btn.primary:not(.ready) { background: #93acf5; border-color: #93acf5; }

/* ---------- dialogs ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(16, 24, 40, 0.45); display: grid; place-items: center; z-index: 50; padding: 1rem; }
.modal { background: #fff; border-radius: 12px; padding: 1.4rem 1.5rem; width: 100%; max-width: 460px; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2); }
.modal.wide { max-width: 720px; }
.modal p { overflow-wrap: anywhere; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1.25rem; }
.link-row { border: 1px solid var(--line); border-radius: 8px; padding: 0.7rem 0.8rem; margin-top: 0.75rem; }
.link-actions { display: flex; gap: 0.4rem; margin-top: 0.45rem; }
.link-input { font-size: 0.82rem; color: var(--muted); }
.sig-pane { margin-top: 0.75rem; }
.sig-pad { display: block; width: 100%; height: 170px; border: 1.5px dashed #98a2b3; border-radius: 8px; background: #fcfcfd; touch-action: none; cursor: crosshair; }
.sig-preview { font-size: 2.4rem; color: #0b1f4d; min-height: 4rem; padding: 0.5rem 0.25rem; border-bottom: 1.5px solid #98a2b3; margin-top: 0.75rem; overflow: hidden; white-space: nowrap; }

/* ---------- toasts ---------- */
.toasts { position: fixed; right: 1rem; bottom: 5rem; z-index: 60; display: flex; flex-direction: column; gap: 0.5rem; max-width: 380px; }
.toast { background: #101828; color: #fff; padding: 0.7rem 0.9rem; border-radius: 8px; font-size: 0.9rem; box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2); }
.toast.error { background: var(--danger); }

/* ---------- small screens ---------- */
@media (max-width: 800px) {
  .editor { grid-template-columns: 1fr; height: auto; }
  .sidebar { border-right: none; }
  .content { padding: 1rem 0.75rem 5rem; }
  .history .when { display: block; }
  .table.docs th:nth-child(4), .table.docs td:nth-child(4) { display: none; }
  .signbar { padding: 0.6rem 0.75rem; }
  .progress-text { font-size: 0.8rem; }
  .brand-sub { display: none; }
  .who { display: none; }
  .topbar, .sign-top { padding: 0.6rem 0.75rem; }
  .card { padding: 1rem; }
  .detail-head { flex-direction: column-reverse; gap: 0.25rem; }
  .table td, .table th { padding: 0.55rem 0.45rem; }
}

/* ---------- DocuSign features (Dec 2026) ---------- */
.badge.s-expired { background: #fef0c7; color: #93370d; }
.notice.n-expired { background: #fffaeb; border-color: #fedf89; }
.lang-switch { display: flex; gap: 0.1rem; margin-left: auto; }
.lang-switch .btn.link { color: var(--muted); }
.lang-switch .btn.link.active { color: var(--accent); font-weight: 700; text-decoration: underline; }
.signing .field.mine.t-attachment { background: #fff4c2; justify-content: flex-start; padding: 0 0.35em; overflow: hidden; white-space: nowrap; }
.signing .field.mine.t-attachment.done { background: rgba(23, 178, 106, 0.08); }
.field.t-attachment .field-text, .field.t-attachment .field-value { overflow: hidden; text-overflow: ellipsis; }
.editing .field.conditional { border-style: dotted !important; }
.editing .field.conditional::before { content: "⤷"; position: absolute; left: -0.9em; top: -0.2em; font-size: 0.8rem; color: var(--muted); }
.attach-dialog .btn.primary { margin-top: 0.25rem; }
.attach-list { margin: 0; padding-left: 1.2rem; }
.attach-list li { margin: 0.3rem 0; }
.correct-row { border: 1px solid var(--line); border-radius: 8px; padding: 0.6rem 0.75rem; margin: 0.6rem 0; }
.correct-row input { margin-bottom: 0.2rem; }
.role-person { display: grid; grid-template-columns: 9rem 1fr 1fr; gap: 0.4rem; align-items: center; margin: 0.3rem 0; }
.form-link-editor .check { margin-top: 0.6rem; }
.bulk-input { width: 100%; font-family: Consolas, "Courier New", monospace; font-size: 0.85rem; margin-top: 0.6rem; }
.table .bad-row td { background: #fef3f2; }
.bulk-results { padding-left: 1.2rem; }
.mt { margin-top: 1rem; }
.card h2.mt { margin-top: 1.4rem; }
.link-actions { display: flex; gap: 0.4rem; align-items: center; margin-top: 0.3rem; }
@media (max-width: 640px) { .role-person { grid-template-columns: 1fr; } .lang-switch { margin-left: 0; } }
.button-row.center { justify-content: center; }

.archive-matches { margin-top: 0.3rem; }
.archive-matches ul { margin: 0.1rem 0 0; padding-left: 1.1rem; }
.archive-matches li { margin: 0.05rem 0; }


/* ---------- PDF preview (viewer.js) ---------- */
body.viewer-open { overflow: hidden; }
.viewer-overlay { position: fixed; inset: 0; z-index: 40; background: #525659; display: flex; flex-direction: column; }
.viewer-bar { display: flex; align-items: center; gap: 0.6rem; padding: 0.5rem 0.9rem; background: #fff; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.viewer-title { max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-jump { max-width: 22rem; width: auto; margin: 0; }
.viewer-page { color: var(--muted); white-space: nowrap; }
.viewer-scroll { flex: 1; overflow-y: auto; padding: 0.75rem; }
.viewer-pages { gap: 0.6rem; }
.viewer-pages .page { box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35); }
.viewer-loading { color: #fff; text-align: center; margin-top: 3rem; }
@media (max-width: 640px) {
  .viewer-title { max-width: 100%; flex-basis: 100%; }
  .viewer-jump { max-width: 60vw; }
  .viewer-scroll { padding: 0.4rem; }
}
