/* e-Sign application styles. Palette: Firmly Linked colors. */
:root {
  --ink: #1f302e; --text: #2b3533; --muted: #66726f; --faint: #8c9895;
  --line: #e2e8e7; --line-2: #d3dcda; --bg: #f4f7f6; --panel: #fff; --hover: #f2f6f5;
  --panel-2: #fbfcfc; --input: #fff; --line-strong: #c4d0cd; --chip: #edf1f0; --track: #e6eceb; --canvas: #e9eeed; --canvas-2: #eef2f1;
  --warn-line: #f0d9a8; --warn-ink: #6e4706; --accent-line: #cdd7f3; --bad-line: #f2c4c6; --toast-bg: #1f302e; --toast-ink: #fff;
  --btn-primary-bg: #2646a6; --btn-primary-border: #2646a6; --btn-primary-ink: #fff; --btn-primary-hover: #1c3684; --link: #2646a6;
  --teal: #7ea9a4; --teal-deep: #406460; --mint: #eef7f6; --green: #376c50; --green-2: #53a278;
  --accent: #2646a6; --accent-2: #1c3684; --accent-soft: #eaeefa;
  --ok: #2f7d55; --ok-soft: #e3f3ea; --warn: #96620b; --warn-soft: #fdf1dc; --bad: #c0262d; --bad-soft: #fde9e9;
  --r: 8px; --font: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 var(--font); color: var(--text); background: var(--bg); -webkit-text-size-adjust: 100%; -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; color: var(--ink); line-height: 1.25; }
h1 { font-size: 20px; font-weight: 650; } h2 { font-size: 14px; font-weight: 650; } h3 { font-size: 14px; font-weight: 600; }
a { color: var(--link); text-decoration: none; } a:hover { text-decoration: underline; }
svg { width: 16px; height: 16px; flex: none; }
.muted { color: var(--muted); } .small { font-size: 13px; } .xs { font-size: 12px; } .nowrap { white-space: nowrap; }
.mono { font-family: var(--mono); font-size: 12px; } .mono-ish { font-family: var(--mono); letter-spacing: .02em; }
.hidden { display: none !important; } .row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; } .spacer { flex: 1; }
.error { color: var(--bad); font-size: 13px; margin-top: 8px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 18px; }

/* controls */
button, .btn { font: inherit; font-size: 13.5px; font-weight: 550; border: 1px solid var(--line-2); background: var(--panel); color: var(--ink); padding: 0 12px; height: 34px; border-radius: var(--r); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none !important; white-space: nowrap; transition: background .12s, border-color .12s; }
button:hover, .btn:hover { background: var(--hover); border-color: var(--line-strong); }
button.primary, .btn.primary { background: var(--btn-primary-bg); border-color: var(--btn-primary-border); color: var(--btn-primary-ink); }
button.primary:hover, .btn.primary:hover { background: var(--btn-primary-hover); border-color: var(--btn-primary-border); }
button.ghost, .btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
button.ghost:hover, .btn.ghost:hover { background: var(--hover); color: var(--ink); }
button.danger { color: var(--bad); } button.danger:hover { background: var(--bad-soft); border-color: var(--bad-line); }
button.sm, .btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
button.icon { width: 30px; padding: 0; }
button.block { width: 100%; height: 38px; }
button:disabled { opacity: .45; cursor: default; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=number], input[type=tel], input[type=date], select, textarea {
  font: inherit; font-size: 14px; height: 36px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: var(--r); width: 100%; background: var(--input); color: var(--ink);
}
textarea { height: auto; padding: 8px 10px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(126,169,164,.22); }
button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin: 12px 0 5px; }
label.inline { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--text); margin: 8px 0; font-size: 13px; }
label.inline input { width: 15px; height: 15px; margin: 0; accent-color: var(--accent); }

.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--chip); color: var(--teal-deep); white-space: nowrap; }
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.chip.signed, .chip.completed { background: var(--ok-soft); color: var(--ok); }
.chip.sent, .chip.pending, .chip.viewed { background: var(--warn-soft); color: var(--warn); }
.chip.declined, .chip.voided { background: var(--bad-soft); color: var(--bad); }
.chip.waiting { background: var(--chip); color: var(--muted); }

.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: var(--toast-bg); color: var(--toast-ink); padding: 9px 14px; border-radius: 8px; z-index: 1000; font-size: 13.5px; box-shadow: 0 8px 24px rgba(0,0,0,.2); }
.banner { background: var(--warn-soft); border: 1px solid var(--warn-line); color: var(--warn-ink); padding: 9px 14px; border-radius: var(--r); margin: 0 0 16px; font-size: 13px; }
.banner.info { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-2); }

/* ---------- application shell ---------- */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 14px 10px; }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; color: var(--ink) !important; font-weight: 700; font-size: 15px; text-decoration: none !important; }
.mark { width: 30px; height: 30px; border-radius: 8px; background: var(--green); color: #fff; display: grid; place-items: center; flex: none; }
.mark svg { width: 17px; height: 17px; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r); color: var(--text); font-weight: 550; text-decoration: none !important; }
.side-nav a svg { color: var(--faint); width: 18px; height: 18px; }
.side-nav a:hover { background: var(--hover); }
.side-nav a.active { background: var(--mint); color: var(--teal-deep); }
.side-nav a.active svg { color: var(--teal-deep); }
.side-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.who { display: flex; align-items: center; gap: 10px; padding: 0 6px; min-width: 0; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--teal); color: #fff; display: grid; place-items: center; font-weight: 700; flex: none; }
.who-t { min-width: 0; display: flex; flex-direction: column; }
.who-t b { font-size: 13px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who-t span { font-size: 12px; color: var(--muted); }
.side-foot button { justify-content: flex-start; width: 100%; }
.main { padding: 22px 28px 40px; min-width: 0; }

/* compact sidebar (editor) */
.app.compact { grid-template-columns: 60px 1fr; }
.app.compact .side { padding: 14px 8px; align-items: center; }
.app.compact .side-brand { padding: 4px 0 16px; }
.app.compact .side-brand span:not(.mark), .app.compact .side-nav span, .app.compact .who-t, .app.compact .side-foot button span { display: none; }
.app.compact .side-nav a { justify-content: center; padding: 9px; }
.app.compact .who { padding: 0; justify-content: center; }
.app.compact .side-foot button { width: 36px; padding: 0; justify-content: center; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 3px; }
.page-head .ph-a { display: flex; gap: 8px; }
.crumb { font-size: 12.5px; color: var(--muted); margin-bottom: 4px; } .crumb span { margin: 0 4px; color: var(--faint); }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.panel + .panel { margin-top: 16px; }
.panel-h { display: flex; align-items: center; justify-content: space-between; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.toolbar { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.seg { display: flex; gap: 2px; background: var(--bg); border: 1px solid var(--line); border-radius: var(--r); padding: 2px; }
.seg button { height: 28px; border: 0; background: transparent; color: var(--muted); font-weight: 550; padding: 0 10px; }
.seg button span { font-size: 11.5px; color: var(--faint); margin-left: 2px; font-weight: 600; }
.seg button.on { background: var(--panel); color: var(--ink); box-shadow: 0 1px 2px rgba(16,24,40,.08); }
.search { position: relative; margin-left: auto; width: 280px; max-width: 100%; }
.search svg { position: absolute; left: 10px; top: 10px; color: var(--faint); width: 15px; height: 15px; }
.search input { padding-left: 32px; height: 34px; }

table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--faint); font-weight: 600; padding: 9px 16px; border-bottom: 1px solid var(--line); background: var(--panel-2); }
table.list td { padding: 11px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list tr:last-child td { border-bottom: 0; }
table.list tr.click { cursor: pointer; } table.list tr.click:hover td { background: var(--hover); }
table.list.dense td { padding: 8px 16px; font-size: 13px; vertical-align: top; }
.ev-d { font-family: var(--mono); font-size: 11.5px; word-break: break-all; margin-top: 2px; }
.doc-name { font-weight: 600; color: var(--ink); }
.prog { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.prog .bar { width: 64px; height: 6px; border-radius: 3px; background: var(--track); overflow: hidden; }
.prog .bar i { display: block; height: 100%; background: var(--green-2); border-radius: 3px; }
.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty b { color: var(--ink); }
.ficon { width: 32px; height: 32px; border-radius: 8px; background: var(--mint); color: var(--teal-deep); display: grid; place-items: center; flex: none; }
.role-tag { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 1px 7px; margin: 2px 4px 2px 0; }
.role-tag i { width: 7px; height: 7px; border-radius: 2px; display: block; }

/* document detail */
.detail { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.d-side { position: sticky; top: 22px; }
.steps { list-style: none; margin: 0; padding: 6px 16px; }
.steps li { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); position: relative; }
.steps li:last-child { border-bottom: 0; }
.st { width: 26px; height: 26px; border-radius: 50%; border: 1.5px solid var(--line-2); color: var(--muted); display: grid; place-items: center; font-size: 12px; font-weight: 700; flex: none; background: var(--panel); }
.st svg { width: 13px; height: 13px; }
.st.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.st.cur { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.st.bad { background: var(--bad); border-color: var(--bad); color: #fff; }
.sb { min-width: 0; flex: 1; }
.kv { display: grid; grid-template-columns: 108px 1fr; gap: 9px 10px; margin: 0; padding: 14px 16px; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; color: var(--ink); min-width: 0; overflow-wrap: anywhere; }
.files { padding: 6px; }
.files a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--r); color: var(--ink); text-decoration: none !important; }
.files a:hover { background: var(--hover); }
.files a svg { color: var(--teal-deep); width: 18px; height: 18px; }
.files a span { display: flex; flex-direction: column; } .files small { color: var(--muted); font-size: 12px; }
.hash { padding: 10px 16px; } .hash + .hash { padding-top: 0; }
.hash span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.hash code { font-family: var(--mono); font-size: 11px; word-break: break-all; color: var(--ink); background: var(--bg); padding: 6px 8px; border-radius: 6px; display: block; }
.d-side .panel > .row { padding: 14px 16px; }
.linkbox { display: flex; gap: 6px; align-items: center; background: var(--bg); border: 1px solid var(--line); border-radius: var(--r); padding: 4px 4px 4px 10px; margin-top: 8px; max-width: 620px; }
.linkbox code { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 12px; color: var(--muted); }

/* modals */
.modal-bg { position: fixed; inset: 0; background: rgba(16,24,22,.4); display: flex; align-items: center; justify-content: center; z-index: 200; padding: 16px; }
.modal { background: var(--panel); border-radius: 12px; width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; padding: 20px 22px; box-shadow: 0 24px 60px rgba(0,0,0,.22); }
.modal h2 { font-size: 17px; }
.modal-h { margin-bottom: 6px; } .modal-h p { margin: 4px 0 0; }
.modal-f { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--line); }
.pick { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.pick-i { height: auto; justify-content: flex-start; gap: 12px; padding: 10px 12px; text-align: left; }
.pi-ic { width: 34px; height: 34px; border-radius: 8px; background: var(--mint); color: var(--teal-deep); display: grid; place-items: center; }
.pi-t { flex: 1; display: flex; flex-direction: column; font-weight: 400; } .pi-t b { font-weight: 600; } .pi-t span { font-size: 12.5px; color: var(--muted); }
.signer-blk { margin-top: 8px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel-2); }
.legend-dot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; vertical-align: 0; }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login { width: 100%; max-width: 380px; padding: 28px; box-shadow: 0 10px 30px rgba(31,48,46,.06); }
.login-mark { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; font-size: 15px; color: var(--ink); }
.login h1 { font-size: 20px; margin-bottom: 6px; }

/* ---------- template editor workspace ---------- */
.main.main-editor { padding: 0; display: flex; flex-direction: column; height: 100vh; }
.main-editor .banner { margin: 10px 16px 0; }
.ed-bar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.ed-name { max-width: 340px; font-weight: 600; height: 32px; border-color: transparent; }
.ed-name:hover { border-color: var(--line-2); }
.ed-jump { gap: 6px; flex-wrap: nowrap; } .ed-jump input { width: 62px; height: 30px; }
.editor { flex: 1; min-height: 0; display: grid; grid-template-columns: 248px minmax(0, 1fr) 292px; }
.ed-left, .ed-right { background: var(--panel); overflow-y: auto; }
.ed-left { border-right: 1px solid var(--line); } .ed-right { border-left: 1px solid var(--line); padding: 14px 16px 24px; }
.ed-sec { padding: 14px 14px 16px; border-bottom: 1px solid var(--line); }
.ed-h { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; font-weight: 650; color: var(--faint); margin-bottom: 10px; }
.ed-sec #roles input { height: 30px; font-size: 13px; }
.ed-sec #addrole { margin-top: 6px; }
.ed-sec select { height: 32px; }
.tools { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 8px; }
.tools button { height: 32px; font-size: 12.5px; justify-content: flex-start; padding: 0 9px; }
.tools button.armed { background: var(--btn-primary-bg); color: var(--btn-primary-ink); border-color: var(--btn-primary-border); }
#hint { margin: 10px 0 0; line-height: 1.45; }
.ed-right label { margin-top: 10px; } .ed-right select, .ed-right input[type=text] { height: 32px; font-size: 13px; }
.props-empty { color: var(--muted); font-size: 13px; padding: 26px 8px; text-align: center; border: 1px dashed var(--line-2); border-radius: var(--r); }
.ed-canvas { overflow: auto; background: var(--canvas); padding: 24px; }
.pages { display: flex; flex-direction: column; align-items: center; gap: 22px; }
.page-wrap { position: relative; box-shadow: 0 1px 3px rgba(0,0,0,.1), 0 6px 18px rgba(31,48,46,.08); background: #fff; }
.page-wrap canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
.page-wrap:not(:has(canvas))::before { content: "Loading page…"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #b0b7c3; font-size: 13px; }
.page-wrap.placing { cursor: crosshair; }
.page-num { position: absolute; top: -17px; left: 0; font-size: 11px; color: var(--muted); }
.fbox { position: absolute; border: 1.5px solid; border-radius: 3px; font-size: 11px; line-height: 1.1; padding: 1px 3px; overflow: hidden; cursor: move; user-select: none; touch-action: none; display: flex; align-items: center; }
.fbox.sel { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--accent); z-index: 5; }
.fbox .rq { color: var(--bad); font-weight: 700; margin-right: 3px; font-size: 13px; flex: none; }
.fbox .ft { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.fbox .lk { font-size: 9px; margin-left: 3px; flex: none; }
.fbox .rs { position: absolute; right: -1px; bottom: -1px; width: 10px; height: 10px; cursor: nwse-resize; background: currentColor; opacity: .75; border-top-left-radius: 3px; }

@media (max-width: 1100px) { .detail { grid-template-columns: 1fr; } .d-side { position: static; } .editor { grid-template-columns: 220px minmax(0,1fr) 260px; } }
@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; } .side { position: static; height: auto; flex-direction: row; align-items: center; padding: 8px 12px; border-right: 0; border-bottom: 1px solid var(--line); }
  .side-brand { padding: 0 8px 0 0; } .side-nav { flex-direction: row; } .side-foot { margin: 0 0 0 auto; border: 0; padding: 0; flex-direction: row; } .who-t { display: none; }
  .main { padding: 16px; } .search { width: 100%; } .editor { grid-template-columns: 1fr; } .ed-left, .ed-right { max-height: 40vh; }
  input, select, textarea { font-size: 16px !important; }
}

/* ---------- signer ---------- */
body.signer { background: var(--canvas-2); padding-bottom: 86px; }
.s-head { background: var(--panel); border-bottom: 1px solid var(--line); padding: 10px 14px; position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: 12px; }
.s-head .t { flex: 1; min-width: 0; }
.s-head .t span { font-size: 12px; } .s-head .t b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink); font-size: 14.5px; }
.firm-mark { width: 34px; height: 34px; border-radius: 8px; background: var(--green); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 15px; flex: none; }
.brand-top { font-size: 12.5px; font-weight: 650; color: var(--teal-deep); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 14px; }
.s-wrap { max-width: 920px; margin: 14px auto; padding: 0 10px; }
.s-wrap > p { font-size: 13px; }
.s-pages { display: flex; flex-direction: column; gap: 14px; }
.s-field { position: absolute; z-index: 3; border: 1.5px solid #7c6cf0; background: rgba(170, 160, 255, .3); border-radius: 3px; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; color: #3b2fa3; cursor: pointer; overflow: hidden; text-align: center; line-height: 1.05; padding: 0 2px; min-height: 0; height: auto; gap: 0; white-space: normal; font-family: inherit; }
.s-field.req::before { content: "*"; color: var(--bad); font-weight: 800; margin-right: 4px; font-size: 1.15em; line-height: 1; }
.s-field.done { border: 1.5px solid var(--teal); background: rgba(126,169,164,.08); color: var(--ink); }
.s-field.done::before { content: none; }
.s-field.fixed { border: 1px dashed #b9cfcc; background: rgba(238,247,246,.6); }
.s-field:hover { background: rgba(170, 160, 255, .45); }
.s-field.done:hover { background: rgba(126,169,164,.18); }
.s-hit { position: absolute; cursor: pointer; z-index: 1; -webkit-tap-highlight-color: transparent; }
.s-field.current { box-shadow: 0 0 0 3px rgba(38,70,166,.45); animation: pulse 1.4s ease-in-out 2; }
.s-field img { max-width: 100%; max-height: 100%; }
.s-field .val { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; font-family: Helvetica, Arial, sans-serif; color: #0d1a59; }
.s-field.auto { border-style: dashed; border-color: #b9cfcc; background: rgba(238,247,246,.55); color: var(--muted); cursor: default; }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px rgba(38,70,166,.15); } }
.s-bar { position: fixed; left: 0; right: 0; bottom: 0; background: var(--panel); border-top: 1px solid var(--line); padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); display: flex; align-items: center; gap: 10px; z-index: 60; }
.s-bar .prog { flex: 1; font-size: 14px; color: var(--text); display: block; }
.s-bar button { height: 44px; padding: 0 20px; font-size: 15px; }
.center-card { max-width: 480px; margin: 9vh auto; padding: 0 14px; }
.center-card .card { padding: 24px; }
.center-card h1 { font-size: 21px; margin-bottom: 10px; }
.center-card p { margin: 0 0 12px; }
.center-card button.primary, .center-card .btn.primary { height: 44px; font-size: 15px; }
.consent-text { font-size: 13.5px; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; max-height: 38vh; overflow: auto; }
.consent-text p { margin: 0 0 8px; }
.sheet-bg { position: fixed; inset: 0; background: rgba(16,24,22,.45); z-index: 300; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--panel); width: 100%; max-width: 600px; border-radius: 14px 14px 0 0; padding: 18px 16px calc(16px + env(safe-area-inset-bottom)); max-height: 94vh; overflow: auto; }
.sheet h2 { font-size: 17px; } .sheet h3 { font-size: 15px; margin-bottom: 10px; }
.sheet input, .sheet select, .sheet textarea { font-size: 16px; height: 44px; } .sheet textarea { height: auto; }
.sheet .row button { height: 40px; }
@media (min-width: 700px) { .sheet-bg { align-items: center; } .sheet { border-radius: 12px; } }
.tabs { display: flex; gap: 2px; background: var(--bg); border: 1px solid var(--line); padding: 2px; border-radius: var(--r); margin: 10px 0 12px; }
.tabs button { flex: 1; border: 0; background: transparent; height: 32px; color: var(--muted); }
.tabs button.on { background: var(--panel); color: var(--ink); box-shadow: 0 1px 2px rgba(16,24,40,.08); }
.pad { position: relative; border: 1px solid var(--line-2); border-radius: 10px; background: #fff; touch-action: none; }
.pad canvas { display: block; width: 100%; height: 190px; touch-action: none; }
.pad .line { position: absolute; left: 6%; right: 6%; bottom: 46px; border-bottom: 1.5px solid #c3c9d4; pointer-events: none; }
.pad .x { position: absolute; left: 6%; bottom: 50px; color: #9aa3b2; font-size: 20px; pointer-events: none; }
.pad .hint { position: absolute; top: 8px; width: 100%; text-align: center; color: #b0b7c3; font-size: 13px; pointer-events: none; }
.typed-preview { background: #fff; height: 120px; border: 1px solid var(--line-2); border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 44px; color: #0d1a59; overflow: hidden; padding: 0 10px; white-space: nowrap; }
.sig-font { font-family: "Segoe Script", "Brush Script MT", "Snell Roundhand", "Apple Chancery", "URW Chancery L", cursive; font-style: italic; }

/* accounts & roles */
.chip.admin { background: var(--accent-soft); color: var(--accent); }
.chip.staff { background: var(--mint); color: var(--teal-deep); }
.avatar.xs-av { width: 22px; height: 22px; font-size: 11px; }
select.issuer { width: auto; height: 34px; min-width: 190px; }
.pi-ic.up { background: var(--accent-soft); color: var(--accent); }

.sendas { display: flex; gap: 8px; align-items: flex-start; margin-top: 14px; padding: 9px 12px; background: var(--mint); border-radius: var(--r); font-size: 12.5px; color: var(--teal-deep); }
.sendas svg { margin-top: 1px; }

/* assigned users */
.picker { display: flex; flex-direction: column; gap: 4px; max-height: 220px; overflow-y: auto; margin-top: 8px; }
.pk { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--r); margin: 0; font-weight: 400; color: var(--text); cursor: pointer; font-size: 13px; }
.pk:hover { background: var(--hover); } .pk input { width: 15px; height: 15px; accent-color: var(--accent); margin: 0; }
.pk:has(input:checked) { border-color: var(--teal); background: var(--mint); }
.pk-t { flex: 1; min-width: 0; display: flex; flex-direction: column; } .pk-t b { font-weight: 600; color: var(--ink); } .pk-t span { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.assigned-list { padding: 10px 16px 14px; display: flex; flex-direction: column; gap: 8px; }
.aw { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.tag-assigned { display: inline-block; margin-top: 4px; font-size: 11px; font-weight: 600; color: var(--accent); background: var(--accent-soft); border-radius: 999px; padding: 1px 8px; }
label.toggle { margin: 0; font-size: 13px; color: var(--muted); white-space: nowrap; }

.rem select { height: 34px; } .rem select:disabled { opacity: .5; }
.rem-sum { padding: 12px 16px 14px; } .rem-sum p { margin: 6px 0 0; }

/* ---------- dark theme: follows the device setting ---------- */
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --ink: #eef0ea; --text: #d6dbd2; --muted: #9ba597; --faint: #7d8679;
    --line: #2d322a; --line-2: #3a4036; --line-strong: #4a5245; --bg: #121411; --panel: #1b1e19; --panel-2: #1f231d; --hover: #252a22; --input: #151813;
    --chip: #262b23; --track: #2c3229; --canvas: #0e100d; --canvas-2: #121411;
    --mint: #20302a; --teal-deep: #9cc7bf; --teal: #6f9c96; --green: #3f7a5a;
    --accent: #a9b4f5; --accent-2: #c3cbff; --accent-soft: #232a4d; --accent-line: #3b4485; --link: #a9b4f5;
    --ok: #7fcf9e; --ok-soft: #1c3326; --warn: #e7b866; --warn-soft: #33290f; --warn-line: #5a4719; --warn-ink: #f0d39a;
    --bad: #ff8a8f; --bad-soft: #3a1d1f; --bad-line: #6b2e32;
    --toast-bg: #eef0ea; --toast-ink: #121411;
    --btn-primary-bg: #252c55; --btn-primary-border: #9aa3e6; --btn-primary-ink: #eef0ff; --btn-primary-hover: #2f3870;
  }
  .card, .panel, .modal, .login { box-shadow: none; }
  .page-wrap { box-shadow: 0 0 0 1px #2d322a, 0 8px 24px rgba(0,0,0,.5); }
  .modal-bg, .sheet-bg { background: rgba(0,0,0,.6); }
  .seg button.on, .tabs button.on { box-shadow: 0 0 0 1px var(--line-2); }
  .chip.admin { background: var(--accent-soft); color: var(--accent); }
  .st.ok { color: #10261a; } .st.bad { color: #2a0f10; }
  .avatar { color: #10201c; }
  input[type=checkbox] { accent-color: #9aa3e6; }
}

/* ---------- sign-in screen ---------- */
.signin-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--bg); }
.signin-card { width: 100%; max-width: 384px; border: 1px solid var(--line-2); border-radius: 20px; background: var(--panel); padding: 40px; text-align: center; }
.wordmark { font-weight: 300; font-size: 48px; line-height: 48px; letter-spacing: -1.2px; margin: 0 0 32px; }
.wordmark span { display: block; }
.wordmark .w1 { color: var(--ink); } .wordmark .w2 { color: #53a278; }
.gbtn { width: 100%; height: auto; padding: 14px 20px; display: inline-flex; align-items: center; justify-content: center; gap: 12px; font-size: 14px; font-weight: 600; border-radius: 10px;
  border: 1px solid var(--btn-primary-border); background: var(--btn-primary-bg); color: var(--btn-primary-ink); text-decoration: none !important; }
.gbtn:hover { background: var(--btn-primary-hover); }
.gbtn svg { width: 18px; height: 18px; }
.signin-msg { margin: 22px auto 0; max-width: 560px; font-size: 14px; }
.signin-msg.err { color: var(--bad); }
.signin-foot { margin-top: 20px; font-size: 13px; color: var(--muted); }
.signin-foot a { color: var(--muted); text-decoration: underline; }
@media (prefers-color-scheme: dark) { .wordmark .w2 { color: #97b08e; } .signin-card { border-color: #383d34; background: #1c1f1a; } .signin-page { background: #131512; } }
@media (max-width: 600px) { .signin-card { padding: 40px 24px; } }
