:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #0f172a;
  --text-2: #475569;
  --muted: #94a3b8;
  --line: #e2e8f0;
  --primary: #1d4ed8;
  --primary-2: #1e40af;
  --primary-soft: #eff6ff;
  --navy: #0f2a5c;
  --ok: #047857; --ok-soft: #ecfdf5;
  --warn: #b45309; --warn-soft: #fffbeb;
  --bad: #b91c1c; --bad-soft: #fef2f2;
  --info: #0369a1; --info-soft: #f0f9ff;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15,23,42,.06), 0 4px 16px rgba(15,23,42,.05);
  --font: 'Inter', 'Segoe UI', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 16px; font-weight: 600; }
h3 { font-size: 14px; font-weight: 600; }
.ic { flex: none; vertical-align: middle; }
.muted { color: var(--text-2); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; word-break: break-all; }
.hidden { display: none !important; }

/* Top bar */
.topbar { background: var(--navy); color: #fff; position: sticky; top: 0; z-index: 50; }
.topbar-inner { max-width: 1280px; margin: 0 auto; display: flex; align-items: center; gap: 18px; padding: 0 20px; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 16px; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 32px; height: 32px; border-radius: 8px; background: var(--primary); display: grid; place-items: center; }
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.nav-link { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 8px; color: #cbd5e1; font-weight: 500; white-space: nowrap; }
.nav-link:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.nav-link.active { background: rgba(255,255,255,.14); color: #fff; }
.nav-link .count { background: #f59e0b; color: #1f2937; border-radius: 10px; font-size: 11px; padding: 0 7px; line-height: 18px; }
.usermenu { position: relative; }
.usermenu summary { list-style: none; cursor: pointer; }
.usermenu summary::-webkit-details-marker { display: none; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: #3b82f6; display: grid; place-items: center; font-weight: 700; color: #fff; }
.usermenu .menu { position: absolute; right: 0; top: 44px; background: #fff; color: var(--text); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.18); min-width: 220px; padding: 6px; }
.usermenu .menu a { display: flex; gap: 8px; align-items: center; padding: 9px 10px; border-radius: 6px; color: var(--text); }
.usermenu .menu a:hover { background: var(--bg); text-decoration: none; }
.menu-head { padding: 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; display: grid; }
.menu-head small { color: var(--text-2); }

/* Layout */
.container { max-width: 1280px; margin: 0 auto; padding: 24px 20px 60px; }
.narrow { max-width: 760px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--text-2); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); gap: 12px; }
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-2 { grid-template-columns: 2fr 1fr; }
@media (max-width: 960px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-2 { grid-template-columns: 1fr; } }

/* Buttons & forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 16px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--text); font: 600 14px var(--font); cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-2); }
.btn-success { background: #059669; border-color: #059669; color: #fff; }
.btn-success:hover { background: #047857; }
.btn-danger { color: var(--bad); border-color: #fecaca; }
.btn-danger:hover { background: var(--bad-soft); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-lg { height: 46px; padding: 0 22px; font-size: 15px; }
.btn-block { width: 100%; }
.topbar .btn-new { height: 36px; }
label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.field { margin-bottom: 16px; }
.hint { font-size: 12px; color: var(--text-2); margin-top: 5px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], select, textarea {
  width: 100%; height: 40px; padding: 0 12px; border: 1px solid #cbd5e1; border-radius: 8px; font: 14px var(--font); color: var(--text); background: #fff;
}
textarea { height: auto; padding: 10px 12px; resize: vertical; min-height: 80px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(29,78,216,.15); }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; }
.check input { margin-top: 3px; width: 16px; height: 16px; }

.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; border: 1px solid; }
.alert-success { background: var(--ok-soft); border-color: #a7f3d0; color: var(--ok); }
.alert-error { background: var(--bad-soft); border-color: #fecaca; color: var(--bad); }
.alert-info { background: var(--info-soft); border-color: #bae6fd; color: var(--info); }
.alert-warn { background: var(--warn-soft); border-color: #fde68a; color: var(--warn); }

/* Badges */
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.st-draft { background: #f1f5f9; color: #475569; }
.st-in_progress { background: var(--warn-soft); color: var(--warn); }
.st-completed { background: var(--ok-soft); color: var(--ok); }
.st-declined, .st-voided, .st-expired { background: var(--bad-soft); color: var(--bad); }
.pill { display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; }
.pill-muted { background: #f1f5f9; color: #64748b; }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-info { background: var(--info-soft); color: var(--info); }
.pill-ok { background: var(--ok-soft); color: var(--ok); }
.pill-bad { background: var(--bad-soft); color: var(--bad); }

/* Stats */
.stat { padding: 18px 20px; display: flex; gap: 14px; align-items: center; color: inherit; }
.stat:hover { text-decoration: none; border-color: #bfdbfe; }
.stat-icon { width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center; }
.stat b { font-size: 26px; display: block; line-height: 1.1; }
.stat span { color: var(--text-2); font-size: 13px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); font-weight: 600; padding: 10px 20px; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.table td { padding: 14px 20px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr.rowlink { cursor: pointer; }
.table tr.rowlink:hover td { background: #f8fafc; }
.doc-title { font-weight: 600; color: var(--text); }
.empty { text-align: center; padding: 48px 20px; color: var(--text-2); }
.empty .ic { color: var(--muted); margin-bottom: 8px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); padding: 0 12px; overflow-x: auto; }
.tab { padding: 12px 12px; color: var(--text-2); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; }
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--primary); border-color: var(--primary); }
.tab small { background: var(--bg); border-radius: 8px; padding: 0 6px; margin-left: 4px; }

/* Auth */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-side { background: linear-gradient(150deg, #0f2a5c, #1d4ed8); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: center; }
.auth-side h1 { font-size: 34px; margin: 18px 0 12px; }
.auth-side p { color: #bfdbfe; font-size: 16px; max-width: 440px; }
.auth-side ul { padding: 0; list-style: none; margin: 26px 0 0; display: grid; gap: 12px; color: #dbeafe; }
.auth-side li { display: flex; gap: 10px; align-items: center; }
.auth-main { display: grid; place-items: center; padding: 32px 20px; }
.auth-card { width: 100%; max-width: 400px; }
@media (max-width: 860px) { .auth-wrap { grid-template-columns: 1fr; } .auth-side { display: none; } }

/* Upload */
.dropzone { border: 2px dashed #93c5fd; background: var(--primary-soft); border-radius: 14px; padding: 48px 20px; text-align: center; cursor: pointer; transition: .15s; }
.dropzone.drag { background: #dbeafe; border-color: var(--primary); }
.dropzone .ic { color: var(--primary); }
.dropzone strong { display: block; font-size: 16px; margin: 10px 0 4px; }
.file-chip { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); margin-top: 14px; }

/* Wizard / prepare */
.steps { display: flex; gap: 0; background: #fff; border-bottom: 1px solid var(--line); padding: 0 20px; position: sticky; top: 60px; z-index: 40; align-items: center; }
.step-btn { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border: 0; background: none; font: 600 14px var(--font); color: var(--text-2); cursor: pointer; border-bottom: 3px solid transparent; }
.step-btn .num { width: 24px; height: 24px; border-radius: 50%; background: #e2e8f0; color: #475569; display: grid; place-items: center; font-size: 12px; }
.step-btn.active { color: var(--primary); border-color: var(--primary); }
.step-btn.active .num { background: var(--primary); color: #fff; }
.step-btn.done .num { background: #059669; color: #fff; }
.steps .spacer { flex: 1; }
.save-state { font-size: 12px; color: var(--muted); margin-right: 12px; }

.flow-types { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 20px; }
.flow-type { border: 2px solid var(--line); border-radius: 12px; padding: 14px; cursor: pointer; background: #fff; text-align: left; font: inherit; color: inherit; }
.flow-type:hover { border-color: #93c5fd; }
.flow-type.active { border-color: var(--primary); background: var(--primary-soft); }
.flow-type strong { display: block; margin: 6px 0 2px; }
.flow-type span { font-size: 12px; color: var(--text-2); }
@media (max-width: 760px) { .flow-types { grid-template-columns: 1fr; } }

.recip { display: grid; grid-template-columns: 34px 70px 1fr 1.2fr 170px 36px; gap: 10px; align-items: center; padding: 12px; border: 1px solid var(--line); border-left: 4px solid var(--c, #2563eb); border-radius: 10px; margin-bottom: 10px; background: #fff; }
.recip .handle { display: grid; gap: 2px; }
.recip .handle button { border: 0; background: none; cursor: pointer; color: var(--text-2); padding: 0; height: 16px; line-height: 16px; }
.recip .handle button:hover { color: var(--primary); }
.recip .order input { text-align: center; padding: 0 4px; }
.recip .order .static { text-align: center; font-weight: 700; color: var(--text-2); }
.recip .rm { border: 0; background: none; color: var(--muted); cursor: pointer; height: 36px; }
.recip .rm:hover { color: var(--bad); }
.recip-wrap { position: relative; }
.suggest { position: absolute; left: 0; right: 0; top: 42px; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); z-index: 20; max-height: 220px; overflow: auto; }
.suggest div { padding: 8px 12px; cursor: pointer; }
.suggest div:hover, .suggest div.on { background: var(--primary-soft); }
.suggest small { color: var(--text-2); display: block; }
@media (max-width: 860px) { .recip { grid-template-columns: 30px 56px 1fr 36px; } .recip .em, .recip .rl { grid-column: 3 / 4; } }

.flowmap { display: flex; align-items: stretch; gap: 0; overflow-x: auto; padding: 6px 2px 10px; }
.flowmap .stepcol { min-width: 170px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.flowmap .stepcol h4 { margin: 0 0 8px; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-2); }
.flowmap .arrow { display: grid; place-items: center; padding: 0 6px; color: var(--muted); font-size: 18px; }
.flowmap .who { display: flex; gap: 8px; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; margin-bottom: 6px; font-size: 13px; }
.flowmap .who i { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.flowmap .who small { color: var(--text-2); display: block; font-size: 11px; }
.flowmap .who.st-completed { border-color: #a7f3d0; }
.flowmap .who.st-declined { border-color: #fecaca; }

/* Field editor */
.editor { display: grid; grid-template-columns: 260px 1fr; height: calc(100vh - 60px - 53px); }
.palette { background: #fff; border-right: 1px solid var(--line); padding: 16px; overflow-y: auto; }
.palette h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-2); margin: 4px 0 10px; }
.palette select { margin-bottom: 18px; }
.ptool { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; margin-bottom: 8px; border: 1px solid var(--line); border-left: 4px solid var(--c); border-radius: 8px; background: #fff; cursor: grab; font: 500 14px var(--font); color: var(--text); text-align: left; }
.ptool:hover { background: var(--surface-2); }
.ptool.armed { background: var(--primary-soft); border-color: var(--primary); border-left-color: var(--c); }
.ptool .sym { width: 22px; text-align: center; font-weight: 700; color: var(--c); }
.props { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 14px; }
.viewer { overflow: auto; background: #e2e8f0; padding: 24px; }
.page-wrap { position: relative; margin: 0 auto 24px; box-shadow: 0 2px 10px rgba(0,0,0,.15); background: #fff; }
.page-wrap canvas { display: block; width: 100%; height: 100%; }
.page-label { text-align: center; font-size: 12px; color: var(--text-2); margin: -16px 0 18px; }
.layer { position: absolute; inset: 0; }
.fld { position: absolute; border: 1.5px solid var(--c); background: color-mix(in srgb, var(--c) 14%, transparent); border-radius: 4px; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; color: var(--c); cursor: move; user-select: none; overflow: hidden; }
.fld.sel { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--c); z-index: 5; }
.fld .lbl { pointer-events: none; padding: 0 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fld .rs { position: absolute; right: -1px; bottom: -1px; width: 12px; height: 12px; background: var(--c); cursor: nwse-resize; border-radius: 2px 0 2px 0; }
.fld .del { position: absolute; top: -1px; right: -1px; width: 18px; height: 18px; border: 0; background: var(--c); color: #fff; font-size: 12px; line-height: 18px; padding: 0; cursor: pointer; border-radius: 0 3px 0 4px; display: none; }
.fld.sel .del { display: block; }
.viewer.armed .layer { cursor: crosshair; }
@media (max-width: 860px) { .editor { grid-template-columns: 1fr; height: auto; } .palette { border-right: 0; border-bottom: 1px solid var(--line); } }

/* Signing */
.signbar { position: sticky; top: 0; z-index: 40; background: #fff; border-bottom: 1px solid var(--line); box-shadow: var(--shadow); }
.signbar-inner { max-width: 1100px; margin: 0 auto; display: flex; align-items: center; gap: 12px; padding: 10px 20px; flex-wrap: wrap; }
.signbar .title { flex: 1; min-width: 200px; }
.signbar .title strong { display: block; font-size: 15px; }
.progress { height: 6px; background: #e2e8f0; border-radius: 3px; overflow: hidden; width: 160px; }
.progress i { display: block; height: 100%; background: #059669; width: 0; transition: width .2s; }
.sign-viewer { background: #e2e8f0; padding: 24px 12px 80px; min-height: calc(100vh - 64px); }
.sign-viewer .page-wrap { max-width: 900px; }
.sfld { position: absolute; border: 2px dashed var(--c); background: color-mix(in srgb, var(--c) 10%, transparent); border-radius: 4px; display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: 12px; font-weight: 700; color: var(--c); overflow: hidden; }
.sfld.req::after { content: '*'; position: absolute; top: 0; right: 4px; color: #dc2626; }
.sfld.filled { border-style: solid; background: rgba(255,255,255,.35); }
.sfld.filled::after { content: ''; }
.sfld.focus { animation: pulse 1s ease 2; box-shadow: 0 0 0 3px #fde047; }
.sfld img { max-width: 100%; max-height: 100%; }
.sfld input[type=text] { border: 0; background: rgba(255,255,255,.85); height: 100%; font-size: 13px; padding: 0 4px; border-radius: 0; }
.sfld .chk { font-size: 18px; color: #0f172a; }
.ofld { position: absolute; display: flex; align-items: center; justify-content: center; font-size: 12px; color: #0f172a; pointer-events: none; overflow: hidden; }
.ofld img { max-width: 100%; max-height: 100%; }
.ofld.pending { border: 1px dashed #cbd5e1; color: #94a3b8; font-size: 10px; }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px #fde047; } }
.done-screen { max-width: 560px; margin: 60px auto; text-align: center; }
.done-screen .big { width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 18px; }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(15,23,42,.55); z-index: 100; display: grid; place-items: center; padding: 16px; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 560px; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.seg { display: flex; gap: 4px; background: var(--bg); padding: 4px; border-radius: 9px; margin-bottom: 14px; }
.seg button { flex: 1; border: 0; background: none; padding: 7px; border-radius: 6px; font: 600 13px var(--font); color: var(--text-2); cursor: pointer; }
.seg button.on { background: #fff; color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.pad { border: 1px solid #cbd5e1; border-radius: 10px; background: #fff; position: relative; touch-action: none; }
.pad canvas { display: block; width: 100%; height: 180px; cursor: crosshair; }
.pad .baseline { position: absolute; left: 24px; right: 24px; bottom: 44px; border-bottom: 1px solid #e2e8f0; pointer-events: none; }
.pad .clear { position: absolute; right: 8px; top: 8px; }
.typed-preview { height: 120px; display: grid; place-items: center; font: 600 44px 'Dancing Script', cursive; border: 1px solid #cbd5e1; border-radius: 10px; margin-top: 10px; overflow: hidden; white-space: nowrap; }

/* Document detail */
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 12px; font-size: 13px; }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; word-break: break-word; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 16px 1fr; gap: 12px; padding-bottom: 14px; position: relative; }
.timeline li::before { content: ''; position: absolute; left: 7px; top: 16px; bottom: 0; width: 2px; background: var(--line); }
.timeline li:last-child::before { display: none; }
.timeline .dot { width: 16px; height: 16px; border-radius: 50%; background: #dbeafe; border: 3px solid #fff; box-shadow: 0 0 0 1px #93c5fd; margin-top: 2px; }
.timeline .dot.ok { background: #a7f3d0; box-shadow: 0 0 0 1px #34d399; }
.timeline .dot.bad { background: #fecaca; box-shadow: 0 0 0 1px #f87171; }
.timeline .meta { font-size: 12px; color: var(--text-2); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

.mail-list { display: grid; grid-template-columns: 340px 1fr; min-height: 70vh; }
.mail-list .items { border-right: 1px solid var(--line); overflow-y: auto; max-height: 75vh; }
.mail-item { display: block; padding: 12px 16px; border-bottom: 1px solid var(--line); color: var(--text); }
.mail-item:hover, .mail-item.on { background: var(--primary-soft); text-decoration: none; }
.mail-item small { color: var(--text-2); display: block; }
.mail-list iframe { width: 100%; height: 75vh; border: 0; }
@media (max-width: 860px) { .mail-list { grid-template-columns: 1fr; } }

.verify-result { display: flex; gap: 16px; align-items: flex-start; padding: 18px; border-radius: 12px; margin-top: 18px; }
.verify-result.ok { background: var(--ok-soft); border: 1px solid #a7f3d0; }
.verify-result.bad { background: var(--bad-soft); border: 1px solid #fecaca; }
.sig-result { padding: 14px 16px; border-radius: 10px; margin-top: 10px; border: 1px solid; border-left-width: 4px; }
.sig-result.ok { background: var(--ok-soft); border-color: #a7f3d0; border-left-color: var(--ok); }
.sig-result.warn { background: var(--warn-soft); border-color: #fde68a; border-left-color: var(--warn); }
.sig-result.bad { background: var(--bad-soft); border-color: #fecaca; border-left-color: var(--bad); }
.sig-result > strong { color: var(--text, #0f172a); }
@media (max-width: 760px) {
  .topbar-inner { gap: 8px; padding: 0 12px; }
  .brand { font-size: 0; gap: 0; }
  .nav-link { padding: 8px; }
  .nav-link span { display: none; }
  .topbar .btn-new { padding: 0 10px; }
  .topbar .btn-new span { display: none; }
  .container { padding: 16px 16px 48px; }
  .page-head form { width: 100%; }
  .page-head input[type=search] { width: 100% !important; flex: 1; }
  .table th:nth-child(4), .table td:nth-child(4), .table th:nth-child(5), .table td:nth-child(5) { display: none; }
  .table th, .table td { padding: 12px; }
  .steps { padding: 0 8px; overflow-x: auto; }
  .step-btn { padding: 12px 8px; font-size: 13px; }
  .save-state { display: none; }
  .signbar .title { min-width: 0; flex-basis: 100%; order: -1; }
  .signbar .progress { width: 90px; }
  .kv { grid-template-columns: 110px 1fr; }
}
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #0f172a; color: #fff; padding: 10px 18px; border-radius: 10px; z-index: 200; font-weight: 500; box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.toast.err { background: #b91c1c; }

/* HRAD staff picker */
.modal.wide { max-width: 720px; }
.staff-tools { display: grid; grid-template-columns: 1fr 220px; gap: 10px; margin-bottom: 12px; }
.staff-list { border: 1px solid var(--line); border-radius: 10px; height: 46vh; overflow: auto; }
.staff-row { display: grid; grid-template-columns: 18px 1fr auto; gap: 12px; align-items: center; padding: 9px 12px; margin: 0; border-bottom: 1px solid var(--line); font-weight: 400; cursor: pointer; }
.staff-row:hover { background: var(--primary-soft); }
.staff-row input { width: 16px; height: 16px; margin: 0; }
.staff-row small { display: block; color: var(--text-2); }
.staff-row .em { text-align: right; overflow-wrap: anywhere; }
.staff-row.is-added { opacity: .6; cursor: default; }
.staff-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 8px; font-size: 12px; color: var(--text-2); }
@media (max-width: 640px) { .staff-tools { grid-template-columns: 1fr; } .staff-row { grid-template-columns: 18px 1fr; } .staff-row .em { grid-column: 2; text-align: left; } }
.suggest .more { padding: 8px 12px; }
.suggest { max-height: 300px; min-width: 280px; }
.set-two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 640px) { .set-two { grid-template-columns: 1fr; } }
.nav { scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
@media (max-width: 1180px) { .topbar-inner { gap: 10px; } .nav { gap: 0; } .nav-link { padding: 8px 9px; gap: 6px; } }

/* Signature pad and saved signatures */
.sig-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; max-height: 44vh; overflow: auto; padding: 3px; }
.sig-card, .font-card { border: 1px solid var(--line); border-radius: 10px; background: #fff; padding: 10px; cursor: pointer; font: inherit; text-align: center; min-width: 0; }
.sig-card img { display: block; width: 100%; height: 64px; object-fit: contain; }
.sig-card span { display: block; font-size: 12px; color: var(--text-2); margin-top: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sig-card.on, .font-card.on, .ink.on { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary); }
.font-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.font-card span { display: block; font-size: 26px; line-height: 44px; height: 44px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.font-card small { color: var(--text-2); }
.sig-tools { display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: center; margin-top: 12px; font-size: 12px; color: var(--text-2); }
.sig-tools > span { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sig-tools select { width: auto; height: 32px; }
.ink { width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 50%; background: #fff; display: inline-grid; place-items: center; padding: 0; margin: 0; cursor: pointer; overflow: hidden; }
.ink span { width: 16px; height: 16px; border-radius: 50%; }
label.ink { background: radial-gradient(circle, #fff 0 26%, transparent 27%), conic-gradient(#dc2626, #d97706, #16a34a, #0891b2, #4f46e5, #c026d3, #dc2626); }
label.ink:focus-within { box-shadow: 0 0 0 2px var(--primary); }
.ink input[type=color] { width: 40px; height: 40px; border: 0; padding: 0; opacity: 0; cursor: pointer; }
.sig-opt { margin-top: 12px; }
.sig-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.sig-list > .empty { grid-column: 1 / -1; }
.sig-item { border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: grid; gap: 10px; min-width: 0; }
.sig-item.is-default { border-color: #a7f3d0; background: var(--ok-soft); }
.sig-item img { width: 100%; height: 80px; object-fit: contain; background: #fff; border-radius: 6px; }
.sig-meta { display: flex; justify-content: space-between; gap: 8px; min-width: 0; }
.sig-meta strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sig-sample { border: 1px dashed var(--line); border-radius: 10px; padding: 14px; margin: 14px 0; text-align: center; min-height: 92px; }
.sig-sample span { display: block; font-size: 32px; line-height: 1.4; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.sig-sample small { color: var(--text-2); }
.modal { max-height: calc(100vh - 32px); display: flex; flex-direction: column; }
.modal-body { overflow: auto; }
.qr { max-width: 240px; margin: 0 auto; }
.qr svg { display: block; width: 100%; height: auto; }
input[type=file] { max-width: 100%; }

.font-card { position: relative; display: block; }
.font-card:has(input) span { padding-left: 20px; }
.font-card input[type=radio] { position: absolute; top: 10px; left: 10px; }
.font-card:has(input:checked) { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary); }
.ink-pick { display: inline-flex; align-items: center; gap: 5px; margin-right: 6px; cursor: pointer; }
.ink-pick i { width: 16px; height: 16px; border-radius: 50%; }
.ink-pick input[type=color] { width: 34px; height: 24px; padding: 0; border: 1px solid var(--line); background: none; }
.sig-add { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.sig-add form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sig-rename { display: flex; gap: 8px; margin-top: 8px; }
.tpl-row { display: block; width: 100%; text-align: left; font: inherit; border: 0; border-bottom: 1px solid var(--line); background: none; padding: 12px; cursor: pointer; }
.tpl-row:hover { background: #f8fafc; }
.tpl-row strong, .tpl-row small { display: block; }
.tpl-row small { color: var(--text-2); margin-top: 2px; }
@media (max-width: 1340px) { .topbar .nav-link span { display: none; } }

.grid-even { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.choice { display: grid; gap: 8px; color: inherit; text-decoration: none; border: 1px solid var(--line); }
.choice:hover { border-color: var(--primary); }
.choice strong { font-size: 16px; }
.choice .ic { color: var(--primary); }
.step-h { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.step-h b { width: 26px; height: 26px; border-radius: 50%; background: #eff6ff; color: #1d4ed8; display: grid; place-items: center; font-size: 13px; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat-row strong { display: block; font-size: 24px; }
.extra-row { display: grid; grid-template-columns: 150px 1fr 160px auto; gap: 8px; margin-bottom: 8px; }
@media (max-width: 700px) { .extra-row { grid-template-columns: 1fr; } }
.who-tag { display: block; font-size: 11px; line-height: 14px; color: var(--muted); margin-top: 4px; }
.who-tag:empty { display: none; }
/* One line of controls, whatever is written under a box */
.recip { align-items: start; --ctl: 40px; }
.recip input, .recip select { height: var(--ctl); margin: 0; }
.recip .handle { height: var(--ctl); align-content: center; }
.recip .order .static { line-height: var(--ctl); }
.recip .rm { height: var(--ctl); }
.who-tag.in { color: #047857; }
@media (max-width: 640px) {
  .recip { grid-template-columns: 30px 64px 1fr 36px; }
  .recip .handle { grid-area: 1 / 1; }
  .recip .order { grid-area: 1 / 2; }
  .recip .rm { grid-area: 1 / 4; }
  .recip .recip-wrap, .recip .em, .recip .rl { grid-column: 1 / -1; width: 100%; }
  .steps { flex-wrap: wrap; height: auto; padding: 4px 12px 8px; row-gap: 6px; overflow: visible; }
  .steps .step-btn { flex: 1 1 0; justify-content: center; white-space: nowrap; font-size: 12px; padding: 8px 4px; }
  .steps .step-btn .num { display: none; }
  .steps .spacer { flex: 0 0 100%; height: 0; }
  .steps #btnDelete { margin-right: auto; }
}
.btn-danger-solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-danger-solid:hover { filter: brightness(.92); }
.notes { margin: 8px 0 0; padding: 8px 12px; border-left: 3px solid var(--bad); text-align: left; overflow-wrap: anywhere; }
.del-list { margin: 0 0 16px; padding-left: 18px; display: grid; gap: 6px; }
.page-head form select { width: auto; }
@media (max-width: 640px) {
  .signbar-inner { gap: 8px; padding: 8px 12px; }
  .signbar .brand-mark { display: none; }
  .signbar-inner > div:not(.title) { flex: 1 1 auto; order: 1; }
  .signbar-inner .progress { width: 100%; }
  .signbar-inner .usermenu { order: 2; }
  .signbar-inner > button { order: 3; flex: 1 1 0; padding: 0 6px; white-space: nowrap; justify-content: center; }
}
.page-step { font-size: 13px; margin-bottom: 10px; line-height: 2.6; }
.page-step input { display: inline-block; width: 58px; height: 34px; padding: 0 6px; }
.mark-box { height: 92px; border: 1px dashed var(--line); border-radius: 10px; display: grid; place-items: center; padding: 8px; margin-bottom: 10px; background: #fff; }
.mark-box img { max-width: 100%; max-height: 74px; }
@media (max-width: 640px) { .signbar-inner:has(#btnSignAll) #btnNextField { display: none; } }
.suggest.float { right: auto; z-index: 60; }
.suggest .more { display: block; padding: 9px 12px; color: var(--text-2); }
.same-row { display: grid; grid-template-columns: 26px 1fr 170px auto auto; gap: 10px; align-items: start; margin-bottom: 10px; }
.same-row.one { grid-template-columns: 26px 1fr; }
.same-row > b { line-height: 40px; color: var(--text-2); text-align: center; }
.same-row .btn { height: 40px; }
.apply-row { display: flex; gap: 10px; }
.apply-row input { max-width: 420px; }
.no-who .col-who, .no-tick .col-tick { display: none; }
@media (max-width: 640px) { .same-row { grid-template-columns: 26px 1fr auto; } .same-row select { grid-column: 2; grid-row: 2; } .same-row [data-sup] { grid-column: 3; grid-row: 1; } .same-row [data-srm] { grid-column: 3; grid-row: 2; } .apply-row { flex-wrap: wrap; } }
.sign-viewer .page-wrap { container-type: inline-size; }
.sign-viewer.placing .layer, .sign-viewer.placing .sfld { cursor: crosshair; }
.page-label .page-rej { margin-left: 10px; }
.page-wrap.rejected canvas { opacity: .45; }
.page-wrap.rejected { outline: 3px solid #dc2626; }
.page-wrap.rejected .sfld { display: none; }
.rej-strip { position: relative; margin: 6px 8px 0; background: #fef2f2; border: 1px solid #dc2626; color: #b91c1c; font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 3px; overflow-wrap: anywhere; z-index: 3; pointer-events: none; }
.tnote { position: absolute; z-index: 4; line-height: 1.25; font-family: Helvetica, Arial, sans-serif; color: #1e3a8a; outline: 1px dashed #93c5fd; outline-offset: 2px; }
.tnote textarea { display: block; width: 100%; min-height: 0; height: auto; border: 0; padding: 0; margin: 0; background: transparent; color: inherit; font: inherit; line-height: inherit; resize: none; overflow: hidden; border-radius: 0; box-shadow: none; outline: 0; }
.tnote:focus-within { outline: 2px solid #1d4ed8; background: rgba(255,255,255,.6); }
.tn-bar { position: absolute; bottom: calc(100% + 5px); left: -2px; display: none; gap: 2px; background: #0f172a; border-radius: 6px; padding: 2px; font: 600 12px/1 Inter, sans-serif; }
.tnote.low .tn-bar { bottom: auto; top: calc(100% + 5px); }
.tnote:hover .tn-bar, .tnote:focus-within .tn-bar { display: flex; }
.tn-bar button, .tn-grip { border: 0; background: transparent; color: #fff; padding: 7px 9px; cursor: pointer; font: inherit; border-radius: 4px; }
.tn-bar button:hover { background: #334155; }
.tn-grip { cursor: move; touch-action: none; }
.tn-rs { position: absolute; right: -8px; top: 0; bottom: 0; width: 12px; cursor: ew-resize; touch-action: none; }
.onote { display: block; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.25; font-family: Helvetica, Arial, sans-serif; color: #1e3a8a; overflow: visible; }
.review { position: fixed; inset: 0; z-index: 90; background: #e2e8f0; display: flex; flex-direction: column; }
.review .sign-viewer { flex: 1; min-height: 0; overflow: auto; position: relative; }
@media (max-width: 640px) { .signbar-inner > button { flex: 1 1 40%; } }
