:root {
  --navy: #092342;
  --navy-2: #12385f;
  --ink: #16304d;
  --muted: #6b7b8d;
  --line: #dce4ed;
  --canvas: #f3f6f9;
  --white: #fff;
  --green: #117b56;
  --green-light: #e8f6f0;
  --red: #b42318;
  --amber: #a65f00;
  --blue: #1469b7;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
.app-body { min-height: 100vh; }
.sign-body { min-height: 100vh; background: linear-gradient(135deg, #eff5f7 0%, #f9fbfc 48%, #e8f0f7 100%); }
.app-shell, .sign-shell { min-height: 100vh; }
.center-card { width: min(420px, calc(100% - 32px)); margin: 13vh auto; padding: 42px; background: var(--white); box-shadow: 0 18px 60px #09234220; border-radius: 18px; text-align: center; }
.mark { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 13px; color: white; background: var(--navy); font-weight: 800; font-size: 23px; box-shadow: 0 7px 18px #09234230; }
.login-logo { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 28px; color: var(--navy); font-weight: 750; font-size: 22px; }
.login-logo .mark { width: 38px; height: 38px; font-size: 20px; }
.login-form { display: grid; gap: 15px; text-align: left; }
label { display: grid; gap: 6px; color: var(--ink); font-size: 13px; font-weight: 650; }
input, select { min-width: 0; padding: 10px 11px; border: 1px solid #cbd6e1; color: var(--ink); background: white; border-radius: 8px; outline: none; }
input:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px #1469b71c; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 38px; padding: 8px 13px; border: 1px solid transparent; border-radius: 8px; background: var(--navy); color: white; font-weight: 700; font-size: 13px; text-decoration: none; }
.button:hover { background: #061c35; }
.button.secondary { background: white; color: var(--navy); border-color: #c8d4df; }
.button.secondary:hover { background: #f4f8fb; }
.button.success { background: var(--green); }
.button.danger { background: white; color: var(--red); border-color: #ecc8c4; }
.button.small { min-height: 31px; padding: 5px 9px; font-size: 12px; }
.button.full { width: 100%; }
.button.icon { width: 34px; padding: 0; }
.toast { position: fixed; z-index: 50; left: 50%; top: 18px; transform: translate(-50%, -140%); padding: 11px 16px; background: #092342; color: white; border-radius: 9px; box-shadow: 0 10px 24px #09234244; font-weight: 650; font-size: 13px; transition: transform .2s ease; max-width: min(520px, calc(100vw - 32px)); }
.toast.visible { transform: translate(-50%, 0); }
.toast.error { background: var(--red); }
.topbar { display: flex; align-items: center; gap: 16px; min-height: 64px; padding: 0 25px; color: white; background: var(--navy); }
.brand { display: flex; align-items: center; gap: 9px; font-size: 17px; font-weight: 750; letter-spacing: -.02em; }
.brand .mark { width: 28px; height: 28px; border-radius: 8px; font-size: 15px; background: #fff; color: var(--navy); box-shadow: none; }
.topbar-spacer { flex: 1; }
.user-email { color: #d7e4f0; font-size: 13px; }
.topbar .button.secondary { border-color: #53718f; color: white; background: transparent; }
.dashboard { max-width: 1160px; margin: 0 auto; padding: 40px 26px; }
.dashboard-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 22px; margin-bottom: 28px; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(25px, 3vw, 36px); letter-spacing: -.035em; margin-bottom: 8px; color: var(--navy); }
h2 { margin-bottom: 6px; font-size: 19px; letter-spacing: -.02em; color: var(--navy); }
h3 { margin-bottom: 6px; font-size: 14px; }
.muted { color: var(--muted); font-size: 14px; line-height: 1.5; }
.card { background: white; border: 1px solid #e1e8ef; border-radius: 12px; box-shadow: 0 3px 11px #09234209; }
.empty { padding: 48px 28px; text-align: center; }
.empty .mark { margin-bottom: 14px; }
.envelope-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 15px; }
.envelope-card { position: relative; display: grid; gap: 13px; padding: 19px; color: inherit; text-decoration: none; transition: transform .15s ease, box-shadow .15s ease; }
.envelope-card:hover { transform: translateY(-2px); box-shadow: 0 10px 25px #09234216; }
.card-title { color: var(--navy); font-weight: 750; font-size: 16px; overflow-wrap: anywhere; }
.card-meta { display: flex; flex-wrap: wrap; gap: 9px; color: var(--muted); font-size: 12px; }
.badge { display: inline-flex; align-items: center; width: max-content; padding: 3px 8px; border-radius: 999px; background: #eaf0f5; color: #496275; font-size: 11px; font-weight: 750; }
.badge.draft { background: #eaf0f5; color: #526779; }
.badge.sent { background: #fff3db; color: var(--amber); }
.badge.completed { background: var(--green-light); color: var(--green); }
.modal-backdrop { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 18px; background: #071e36a8; }
.modal { width: min(480px, 100%); padding: 23px; background: white; border-radius: 13px; box-shadow: 0 25px 80px #0004; }
.modal form { display: grid; gap: 15px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 5px; }
.editor { display: grid; grid-template-columns: 275px minmax(0, 1fr) 260px; min-height: calc(100vh - 64px); }
.editor-side { padding: 20px; background: #fff; border-right: 1px solid var(--line); overflow-y: auto; }
.editor-side.right { border-right: 0; border-left: 1px solid var(--line); }
.editor-side h3 { margin-top: 22px; color: var(--navy); }
.editor-side h3:first-child { margin-top: 0; }
.editor-main { min-width: 0; display: flex; flex-direction: column; background: #e9eef3; }
.editor-title { display: flex; align-items: center; gap: 12px; padding: 15px 20px; background: white; border-bottom: 1px solid var(--line); }
.editor-title input { flex: 1; border: 0; padding: 4px 0; border-radius: 0; color: var(--navy); font-size: 17px; font-weight: 750; }
.editor-title input:focus { box-shadow: 0 2px 0 var(--blue); }
.step-list, .doc-list, .signer-list, .tool-list { display: grid; gap: 7px; }
.item-row { display: flex; align-items: center; gap: 8px; padding: 8px 9px; border: 1px solid transparent; border-radius: 8px; font-size: 13px; }
.item-row.selectable { cursor: pointer; }
.item-row.selectable:hover, .item-row.active { background: #edf5fb; border-color: #d5e6f5; }
.item-row .grow { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tiny { font-size: 11px; color: var(--muted); }
.remove { flex: 0 0 auto; width: 22px; height: 22px; padding: 0; border: none; background: transparent; color: #9a5560; font-size: 18px; line-height: 1; }
.side-form { display: grid; gap: 7px; margin-top: 9px; }
.side-form .inline { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.tool { display: flex; align-items: center; width: 100%; padding: 8px 9px; border: 1px solid #d6e0e9; border-radius: 7px; color: var(--navy); background: white; text-align: left; font-size: 12px; font-weight: 700; }
.tool:hover { background: #f1f7fb; border-color: #bdd8ee; }
.tool .tool-icon { width: 24px; color: var(--blue); font-size: 17px; }
.page-toolbar { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 8px; padding: 11px 16px; background: white; border-bottom: 1px solid var(--line); }
.page-toolbar .page-label { min-width: 92px; text-align: center; color: var(--muted); font-size: 12px; font-weight: 700; }
.canvas-scroller { flex: 1; overflow: auto; padding: 28px; }
.pdf-stage { position: relative; width: min(100%, 820px); margin: 0 auto; background: white; box-shadow: 0 10px 25px #0923422b; line-height: 0; }
.pdf-stage canvas { display: block; width: 100%; height: auto; }
.field-layer { position: absolute; inset: 0; line-height: normal; }
.editor-field { position: absolute; display: flex; align-items: center; min-width: 10px; padding: 2px 4px; border: 1.5px solid var(--field, #1475c1); background: color-mix(in srgb, var(--field, #1475c1) 12%, transparent); color: var(--field, #1475c1); border-radius: 3px; cursor: move; overflow: hidden; font-size: clamp(9px, 1.25vw, 12px); font-weight: 750; user-select: none; }
.editor-field.selected { box-shadow: 0 0 0 3px #e7a41a80; border-color: #b77200; z-index: 2; }
.editor-field .field-tag { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-empty { width: min(100%, 620px); margin: 9vh auto; padding: 36px; text-align: center; border: 2px dashed #bfd0df; border-radius: 13px; color: var(--muted); }
.inspector { display: grid; gap: 11px; }
.inspector .coord-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.inspector label { font-size: 11px; }
.inspector input, .inspector select { padding: 7px; font-size: 12px; }
.check-label { display: flex; align-items: center; gap: 7px; color: var(--ink); font-size: 12px; font-weight: 650; }
.check-label input { min-width: auto; }
.hint { padding: 10px; border-radius: 8px; color: #596c7e; background: #f3f7fa; font-size: 12px; line-height: 1.45; }
.completed-panel { padding: 18px; border-radius: 10px; background: var(--green-light); }
.completed-panel h3 { color: var(--green); }
.sign-header { display: flex; align-items: center; min-height: 65px; padding: 0 28px; background: white; border-bottom: 1px solid var(--line); }
.sign-header .brand { color: var(--navy); }
.sign-header .brand .mark { color: white; background: var(--navy); }
.sign-header .right-note { margin-left: auto; color: var(--muted); font-size: 13px; }
.verification { width: min(500px, calc(100% - 32px)); margin: 9vh auto; padding: 34px; text-align: center; }
.verification h1 { margin-top: 18px; }
.code-input { width: 240px; margin: 17px auto; padding: 13px; font-size: 25px; font-weight: 750; letter-spacing: 8px; text-align: center; }
.signer-workspace { display: grid; grid-template-columns: minmax(0, 1fr) 310px; min-height: calc(100vh - 65px); }
.signer-main { min-width: 0; display: flex; flex-direction: column; }
.signer-sidebar { padding: 22px; background: white; border-left: 1px solid var(--line); overflow-y: auto; }
.signer-sidebar h2 { font-size: 17px; }
.sign-doc-tabs { display: flex; gap: 7px; overflow-x: auto; padding: 12px 19px 0; background: white; border-bottom: 1px solid var(--line); }
.sign-doc-tab { padding: 8px 11px; border: 1px solid transparent; border-bottom: 0; border-radius: 8px 8px 0 0; background: transparent; color: var(--muted); font-size: 12px; font-weight: 700; white-space: nowrap; }
.sign-doc-tab.active { color: var(--navy); border-color: var(--line); background: #f7fafc; }
.sign-field { position: absolute; display: flex; align-items: center; min-width: 10px; padding: 2px 4px; border: 1px solid var(--field, #177c58); border-radius: 3px; background: color-mix(in srgb, var(--field, #177c58) 9%, white); color: var(--ink); overflow: hidden; font-size: clamp(8px, 1.25vw, 13px); }
.sign-field input, .sign-field select { width: 100%; height: 100%; min-height: 0; padding: 0 3px; border: 0; background: transparent; color: var(--ink); font-size: inherit; outline: none; }
.sign-field.auto { color: #315671; font-weight: 700; }
.sign-field.checkbox, .sign-field.strike { justify-content: center; }
.sign-field.checkbox input, .sign-field.strike input { width: min(24px, 100%); height: min(24px, 100%); accent-color: var(--green); }
.signature-button { width: 100%; height: 100%; min-height: 0; padding: 0; overflow: hidden; border: 0; color: #16304d; background: transparent; font-family: cursive; font-size: inherit; text-align: left; }
.signature-button.empty { font-family: inherit; color: var(--green); font-size: 11px; font-weight: 750; }
.field-status { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid #edf1f4; font-size: 12px; }
.field-status .dot { width: 8px; height: 8px; border-radius: 999px; background: #c3cdd5; }
.field-status.done .dot { background: var(--green); }
.signature-modal { width: min(600px, 100%); }
.signature-options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.signature-choice { min-height: 80px; padding: 12px; border: 1px solid #cddae5; border-radius: 9px; background: white; color: var(--navy); text-align: left; }
.signature-choice strong { display: block; margin-bottom: 8px; font-family: cursive; font-size: 24px; font-weight: 500; }
.signature-pad { width: 100%; height: 190px; margin-top: 14px; border: 1px dashed #8da6b8; border-radius: 8px; background: #fff; touch-action: none; }
.signature-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 10px; }
.error-text { color: var(--red); font-size: 12px; }
@media (max-width: 980px) {
  .editor { grid-template-columns: 235px minmax(0, 1fr); }
  .editor-side.right { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--line); }
  .editor-side.right .inspector { max-width: 580px; }
  .signer-workspace { grid-template-columns: 1fr; }
  .signer-sidebar { border-left: 0; border-top: 1px solid var(--line); }
}
@media (max-width: 680px) {
  .topbar { padding: 0 14px; }
  .user-email { display: none; }
  .dashboard { padding: 28px 15px; }
  .dashboard-head { display: block; }
  .dashboard-head .button { margin-top: 15px; }
  .editor { display: block; }
  .editor-side { border-right: 0; border-bottom: 1px solid var(--line); }
  .editor-side.right { border-top: 0; }
  .editor-main { min-height: 72vh; }
  .canvas-scroller { padding: 14px 8px; }
  .sign-header { padding: 0 15px; }
  .sign-header .right-note { display: none; }
  .verification { padding: 26px 18px; }
}
