:root {
  --paper: #F6F7F9;
  --surface: #FFFFFF;
  --ink: #1A2233;
  --ink-2: #4A5468;
  --ink-3: #7A8396;
  --rule: #DCE0E7;
  --rule-2: #EDF0F4;
  --pen: #1F45C4;
  --pen-soft: #E8EDFB;
  --seal: #1D7650;
  --seal-soft: #E3F2EA;
  --wax: #B23A2F;
  --wax-soft: #F8E7E5;
  --amber: #8A5A00;
  --amber-soft: #FBF1DC;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --radius: 6px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--paper); color: var(--ink); font: 15px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: var(--pen); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 24px; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 18px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 650; }
p { margin: 0 0 .8em; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }
.hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--pen); outline-offset: 2px; }

/* ---------- Buttons and inputs ---------- */
button, .btn {
  font: inherit; font-size: 14px; font-weight: 550; border-radius: var(--radius); border: 1px solid var(--rule);
  background: var(--surface); color: var(--ink); padding: 7px 14px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; line-height: 1.3;
}
button:hover, .btn:hover { border-color: #BCC3CF; }
button:disabled { opacity: .55; cursor: default; }
.primary { background: var(--pen); border-color: var(--pen); color: #fff; }
.primary:hover { filter: brightness(1.08); border-color: var(--pen); }
.danger { color: var(--wax); }
.danger.solid { background: var(--wax); border-color: var(--wax); color: #fff; }
.link { border: 0; background: none; padding: 0; color: var(--pen); font-weight: 500; }
.ms { background: #fff; border-color: #8C93A0; }
.ms svg { width: 16px; height: 16px; }
label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin: 0 0 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], select, textarea {
  font: inherit; width: 100%; padding: 8px 10px; border: 1px solid var(--rule); border-radius: var(--radius); background: #fff; color: var(--ink);
}
textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--pen); box-shadow: 0 0 0 3px var(--pen-soft); }
.field { margin-bottom: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; min-width: 140px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--ink); font-size: 14px; }
.check input { width: 16px; height: 16px; accent-color: var(--pen); }
.error { background: var(--wax-soft); color: var(--wax); padding: 10px 12px; border-radius: var(--radius); white-space: pre-wrap; font-size: 14px; margin-bottom: 14px; }
.note { background: var(--amber-soft); color: var(--amber); padding: 10px 12px; border-radius: var(--radius); font-size: 14px; margin-bottom: 14px; }

/* ---------- Sign-in screens ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.auth-side { background: var(--ink); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-side .mark { font-weight: 700; font-size: 18px; }
.auth-side blockquote { margin: 0; font-family: var(--serif); font-size: 30px; line-height: 1.3; max-width: 16em; }
.auth-side .sig { font-family: var(--serif); font-style: italic; font-size: 34px; color: #9DB3FF; border-bottom: 1px solid #56607A; display: inline-block; padding: 0 30px 2px 4px; margin-top: 28px; }
.auth-side .muted { color: #A3ACBE; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-box { width: 100%; max-width: 380px; }
.auth-box h1 { margin-bottom: 6px; }
.auth-box .sub { color: var(--ink-3); margin-bottom: 24px; }
.or { display: flex; align-items: center; gap: 12px; color: var(--ink-3); font-size: 13px; margin: 18px 0; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--rule); }
.wide { width: 100%; justify-content: center; padding: 10px 14px; }
@media (max-width: 820px) { .auth { grid-template-columns: 1fr; } .auth-side { display: none; } }

/* ---------- App shell ---------- */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--rule); padding: 18px 12px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side .org { padding: 4px 10px 16px; }
.side .org strong { display: block; font-size: 15px; }
.side .org span { font-size: 12px; color: var(--ink-3); }
.side .new { margin: 0 4px 14px; justify-content: center; }
.nav { display: flex; justify-content: space-between; align-items: center; padding: 7px 10px; border-radius: var(--radius); color: var(--ink-2); text-decoration: none; font-size: 14px; font-weight: 500; }
.nav:hover { background: var(--rule-2); }
.nav.on { background: var(--pen-soft); color: var(--pen); font-weight: 600; }
.nav .n { font-size: 12px; color: var(--ink-3); }
.nav.on .n { color: var(--pen); }
.side .group { font-size: 12px; color: var(--ink-3); padding: 16px 10px 4px; }
.side .me { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--rule-2); font-size: 13px; }
.side .me div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.main { padding: 28px 32px 60px; min-width: 0; }
.head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.topbar { display: none; }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; position: fixed; inset: 0 25% 0 0; z-index: 30; height: auto; box-shadow: 0 0 0 100vmax rgba(26, 34, 51, .35); }
  .side.open { display: flex; }
  .topbar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--rule); position: sticky; top: 0; z-index: 20; }
  .main { padding: 20px 16px 60px; }
}

/* ---------- Tables and lists ---------- */
.table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--ink-3); padding: 10px 14px; border-bottom: 1px solid var(--rule); background: #FBFBFC; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--rule-2); vertical-align: middle; font-size: 14px; }
  .table select { width: auto; min-width: 120px; padding: 6px 8px; }
.table tr:last-child td { border-bottom: 0; }
.table tr.click { cursor: pointer; }
.table tr.click:hover td { background: #FAFBFD; }
.table .t { font-weight: 600; }
.scroll { overflow-x: auto; }
.empty { background: var(--surface); border: 1px dashed var(--rule); border-radius: var(--radius); padding: 40px 24px; text-align: center; color: var(--ink-2); }
.empty h2 { color: var(--ink); }
.panel { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; }
.panel > h2:first-child, .panel > h3:first-child { margin-top: 0; }
.searchbar { max-width: 320px; }

.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--rule-2); color: var(--ink-2); white-space: nowrap; }
.pill.draft { background: var(--rule-2); color: var(--ink-2); }
.pill.sent, .pill.viewed, .pill.invited { background: var(--amber-soft); color: var(--amber); }
.pill.completed, .pill.signed, .pill.active { background: var(--seal-soft); color: var(--seal); }
.pill.declined, .pill.voided, .pill.expired, .pill.disabled, .pill.suspended { background: var(--wax-soft); color: var(--wax); }
.pill.waiting { background: var(--rule-2); color: var(--ink-3); }
.progress { display: inline-flex; gap: 3px; vertical-align: middle; margin-right: 6px; }
.progress i { width: 14px; height: 4px; border-radius: 2px; background: var(--rule); }
.progress i.done { background: var(--seal); }

/* ---------- The paper ---------- */
.paper {
  background: #fff; border: 1px solid var(--rule); box-shadow: 0 1px 0 var(--rule), 0 8px 24px -16px rgba(26, 34, 51, .25);
  max-width: 760px; margin: 0 auto; padding: 64px 72px; min-height: 600px;
}
.paper-body { min-height: 520px; }
.paper-body[contenteditable] { outline: none; cursor: text; }
.paper:focus-within { border-color: #C3CADA; }
.paper-body.dropping { outline: 2px dashed var(--pen); outline-offset: 8px; border-radius: 2px; }

/* Letterhead */

/* Tables inside documents */
.paper-body[contenteditable] td:empty::after, .paper-body[contenteditable] th:empty::after { content: "\00a0"; }
.toolbar .tbltools { display: inline-flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.toolbar .tbltools.hidden { display: none !important; }

/* Field palette */
.palette-wrap { border: 1px solid var(--rule); border-radius: var(--radius); padding: 12px; margin-bottom: 14px; background: #FBFCFD; }
.palette { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 12.5px; padding: 5px 10px; border-radius: 99px; cursor: grab; background: #fff; }
.chip:active { cursor: grabbing; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 10px; color: var(--ink-2); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; vertical-align: middle; }
.fcard[draggable="true"] { cursor: grab; }
@media (max-width: 860px) { .paper { padding: 32px 22px; min-height: 360px; } .paper.sfdoc { font-size: 16px; } .sfdoc .sf-cols { grid-template-columns: 1fr; } }

/* Fields on the paper: pen-blue ink tabs */
.slot { font-family: var(--sans); font-size: .82em; display: inline-block; padding: 1px 8px; border-radius: 4px; background: var(--pen-soft); color: var(--pen); border-bottom: 2px solid var(--pen); font-weight: 600; vertical-align: baseline; line-height: 1.5; }
.slot.filled { background: transparent; color: var(--ink); border-bottom: 1px solid #9AA3B5; font-family: var(--serif); font-size: 1em; font-weight: 500; padding: 0 2px; border-radius: 0; }
.slot.mine { background: #FFF6D6; color: #6B4E00; border-bottom-color: #E0A800; }
.slot.other { background: var(--rule-2); color: var(--ink-3); border-bottom-color: #B3BAC7; }
.slot.missing { background: var(--wax-soft); color: var(--wax); border-bottom-color: var(--wax); }
.raw-ph { --c: var(--pen); color: var(--c); background: color-mix(in srgb, var(--c) 11%, white); border-bottom: 2px solid var(--c); border-radius: 3px 3px 0 0; padding: 0 3px; font-family: var(--sans); font-size: .85em; }
.raw-if { color: var(--seal); background: var(--seal-soft); border-radius: 3px; padding: 0 2px; font-family: var(--sans); font-size: .85em; }

/* ---------- Editor ---------- */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 390px; gap: 22px; align-items: start; }
.editor-left { min-width: 0; }
.titlebar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.titlebar input { font-size: 20px; font-weight: 650; border-color: transparent; background: transparent; padding: 4px 8px; flex: 1; min-width: 200px; }
.titlebar input:hover { border-color: var(--rule); }
.saved { font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.toolbar { display: flex; gap: 4px; flex-wrap: wrap; position: sticky; top: 0; z-index: 5; background: var(--paper); padding: 6px 0 10px; max-width: 760px; margin: 0 auto; }
.toolbar button { padding: 5px 10px; font-size: 13px; }
.toolbar .sep { width: 1px; background: var(--rule); margin: 2px 4px; }
.toolbar .on { background: var(--ink); color: #fff; border-color: var(--ink); }
.dock { position: sticky; top: 16px; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); max-height: calc(100vh - 32px); display: flex; flex-direction: column; }
.tabs { display: flex; border-bottom: 1px solid var(--rule); overflow-x: auto; flex-shrink: 0; }
.tabs button { border: 0; border-radius: 0; background: none; padding: 11px 9px; font-size: 13px; color: var(--ink-3); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--pen); }
.dock-body { padding: 16px; overflow-y: auto; }
.fcard { border: 1px solid var(--rule); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; }
.fcard .top { display: flex; gap: 6px; align-items: center; margin-bottom: 8px; }
.fcard .top input { font-weight: 600; }
.fcard .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.fcard code, .code { font-family: var(--mono); font-size: 12px; background: var(--rule-2); padding: 1px 5px; border-radius: 3px; }
.who { flex-shrink: 0; display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 4px; }
.rcard { border: 1px solid var(--rule); border-radius: var(--radius); padding: 10px; margin-bottom: 8px; display: grid; grid-template-columns: 44px 1fr; gap: 8px; }
.rcard .step { font-size: 11px; color: var(--ink-3); text-align: center; }
.rcard .step input { text-align: center; padding: 6px 2px; }
.ai-out { white-space: pre-wrap; background: var(--rule-2); border-radius: var(--radius); padding: 12px; font-size: 14px; margin-top: 12px; }
@media (max-width: 1100px) { .editor { grid-template-columns: 1fr; } .dock { position: static; max-height: none; } }

/* ---------- Document detail ---------- */
.detail { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 22px; align-items: start; }
@media (max-width: 1100px) { .detail { grid-template-columns: 1fr; } }
.steps { list-style: none; padding: 0; margin: 0; }
.steps li { display: grid; grid-template-columns: 26px 1fr auto; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--rule-2); align-items: start; }
.steps li:last-child { border-bottom: 0; }
.steps .num { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--rule-2); color: var(--ink-2); }
.steps .num.done { background: var(--seal); color: #fff; }
.trail { font-size: 13px; }
.trail div { overflow-wrap: anywhere; padding: 6px 0; border-bottom: 1px solid var(--rule-2); }
.trail time { color: var(--ink-3); font-size: 12px; display: block; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Toast and modal ---------- */
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: var(--radius); font-size: 14px; z-index: 100; max-width: 90vw; }
.modal-bg { position: fixed; inset: 0; background: rgba(26, 34, 51, .45); display: grid; place-items: center; z-index: 90; padding: 16px; }
.modal { background: #fff; border-radius: 8px; padding: 22px; width: 100%; max-width: 460px; max-height: 90vh; overflow: auto; }
.modal .actions { justify-content: flex-end; margin-top: 18px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- Signer page ---------- */
.sign-top { background: var(--surface); border-bottom: 1px solid var(--rule); padding: 12px 24px; display: flex; justify-content: space-between; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 10; }
.sign-top strong { font-size: 15px; }
.sign-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; padding: 24px; max-width: 1200px; margin: 0 auto; align-items: start; }
.sign-panel { position: sticky; top: 76px; }
@media (max-width: 960px) { .sign-wrap { grid-template-columns: 1fr; padding: 16px; } .sign-panel { position: static; order: -1; } }
.center-box { max-width: 440px; margin: 60px auto; padding: 0 16px; }
.pad { border: 1px solid var(--rule); border-radius: var(--radius); background: #fff; touch-action: none; width: 100%; height: 140px; display: block; cursor: crosshair; }
.typed-preview { font-family: var(--serif); font-style: italic; font-size: 30px; color: #13308F; border-bottom: 1px solid #6E778A; padding: 4px; min-height: 52px; }
.codebox { font-size: 26px; letter-spacing: .4em; text-align: center; font-family: var(--mono); }

/* Editor-only views of layout blocks */
.paper-body[contenteditable] .sf-pagebreak { height: auto; border-top: 2px dashed #B3BAC7; margin: 1.6em 0; position: relative; }
.paper-body[contenteditable] .sf-pagebreak::after { content: "Page break"; position: absolute; top: -10px; left: 50%; transform: translateX(-50%); background: #fff; padding: 0 8px; font: 600 11px var(--sans); color: var(--ink-3); }
.paper .sf-pagebreak { border-top: 1px dashed #DCE0E7; margin: 1.6em 0; }
.paper-body[contenteditable] .sf-col { outline: 1px dashed #DCE0E7; outline-offset: 4px; }
.paper-body[contenteditable] img { cursor: pointer; }
.paper-body[contenteditable] img.selected { outline: 3px solid var(--pen); outline-offset: 2px; }
.paper .items-chip { display: block; }
.toolbar select { width: auto; padding: 5px 6px; font-size: 13px; border-radius: var(--radius); }
.toolbar .swatches { display: none; position: absolute; z-index: 20; background: #fff; border: 1px solid var(--rule); border-radius: var(--radius); padding: 8px; box-shadow: 0 8px 24px -10px rgba(26,34,51,.3); grid-template-columns: repeat(6, 22px); gap: 6px; }
.toolbar .swatches.open { display: grid; }
.toolbar .swatches button { width: 22px; height: 22px; padding: 0; border-radius: 4px; }
.toolbar .dd { position: relative; display: inline-block; }
.toolbar .imgtools.hidden { display: none !important; }
.toolbar .imgtools { display: inline-flex; gap: 4px; align-items: center; }
.items-editor { overflow-x: auto; }
.items-editor table { width: 100%; border-collapse: collapse; font-size: 13px; }
.items-editor th { text-align: left; font-size: 12px; color: var(--ink-3); font-weight: 600; padding: 4px; }
.items-editor td { padding: 3px; }
.items-editor input { padding: 6px 7px; font-size: 13px; }
.items-editor .tot { text-align: right; font-size: 13px; margin-top: 6px; }
.colrow { display: grid; grid-template-columns: 1fr 110px 28px; gap: 6px; margin-bottom: 6px; align-items: center; }
.cond-desc { font-size: 12px; color: var(--seal); }

/* Attached files */
.attach-box { border: 1px dashed var(--rule); border-radius: 8px; padding: 10px; background: #fff; }
.attach-box .row { gap: 8px; flex-wrap: wrap; align-items: baseline; }
.attach-box a { word-break: break-all; }
.filelist { display: flex; flex-direction: column; gap: 6px; margin: 8px 0 12px; }
.filelist .filerow { display: flex; gap: 8px; align-items: baseline; justify-content: space-between; padding: 8px 10px; border: 1px solid var(--rule-2); border-radius: 8px; background: #fff; }
.filelist .filerow a { word-break: break-all; }
.filelist .filerow .meta { flex: 1; min-width: 0; }
.dropzone { border: 2px dashed var(--rule); border-radius: 10px; padding: 18px; text-align: center; color: var(--ink-3); }
.dropzone.over { border-color: var(--pen); background: #f2f6ff; }
.pill.skipped { background: var(--rule-2); color: var(--ink-3); text-decoration: line-through; }
.cond-chip { display: inline-block; background: #eef3ff; color: var(--pen); border-radius: 6px; padding: 2px 6px; }

/* Uploaded PDF with field boxes */
.pdfpages { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.pdfpage { position: relative; width: 100%; max-width: 900px; background: #fff; box-shadow: 0 1px 3px rgba(20,30,50,.12), 0 8px 24px rgba(20,30,50,.06); user-select: none; }
.pdfpage canvas { display: block; width: 100%; height: 100%; }
.pdf-overlay { position: absolute; inset: 0; }
.pdfpage-num { margin: 2px 0 16px; }
.pbox { position: absolute; container-type: size; box-sizing: border-box; border: 1.5px solid var(--c); background: color-mix(in srgb, var(--c) 14%, transparent); border-radius: 3px; display: flex; align-items: center; overflow: visible; touch-action: none; }
.pbox.has-value { background: color-mix(in srgb, var(--c) 6%, transparent); }
.pbox .pval { flex: 1; min-width: 0; padding: 0 3px; font-family: Helvetica, Arial, sans-serif; font-size: clamp(6px, 68cqh, 15px); line-height: 1.1; color: #0d1a4d; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pbox.t-checkbox .pval { text-align: center; padding: 0; font-size: clamp(6px, 90cqh, 20px); }
.pbox .pval img { display: block; max-height: 100cqh; max-width: 100%; }
.pbox .pval .typed { font-family: Georgia, 'Times New Roman', serif; font-style: italic; font-size: clamp(8px, 70cqh, 28px); }
.pbox .plabel { color: var(--c); font-weight: 600; opacity: .9; }
.pbox.edit { cursor: move; }
.pbox.sel { outline: 2px solid var(--c); outline-offset: 1px; z-index: 2; }
.pbox .pdel { display: none; position: absolute; top: -9px; right: -9px; width: 18px; height: 18px; padding: 0; border-radius: 50%; border: 0; background: var(--c); color: #fff; font-size: 13px; line-height: 18px; cursor: pointer; }
.pbox .pres { display: none; position: absolute; right: -5px; bottom: -5px; width: 10px; height: 10px; background: var(--c); border-radius: 2px; cursor: nwse-resize; }
.pbox.edit:hover .pdel, .pbox.edit.sel .pdel, .pbox.edit:hover .pres, .pbox.edit.sel .pres { display: block; }
.pbox.mine { cursor: pointer; background: #fff7c2; border-color: #c99a00; --c: #8a6a00; animation: none; }
.pbox.mine.has-value { background: rgba(255, 247, 194, .5); }
.pbox.other.no-value { opacity: .55; }
.pbox.readonly.no-value { opacity: .4; }
.pdfbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; padding: 10px 12px; margin-bottom: 12px; background: #fff; border: 1px solid var(--rule); border-radius: 10px; }
.pdfbar .hint { flex: 1 1 260px; }
.fcard.sel { outline: 2px solid var(--pen); outline-offset: -1px; }
.stats { display: flex; flex-wrap: wrap; gap: 12px; margin: 4px 0 18px; }
.stat { flex: 1 1 140px; background: var(--surface, #fff); border: 1px solid var(--rule); border-radius: 10px; padding: 12px 14px; }
.stat b { display: block; font-size: 26px; line-height: 1.1; }
.stat span { font-size: 13px; color: var(--ink-3); }
.stat.bad b { color: var(--wax); }
.chart .tip { position: absolute; pointer-events: none; background: var(--ink); color: #fff; font-size: 12px; padding: 4px 8px; border-radius: 6px; white-space: nowrap; }
.chart-legend { display: flex; gap: 14px; flex-wrap: wrap; color: var(--ink-2); }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

/* Phone-friendly signing */
.sign-bar { display: none; }
.sig-prev { display: block; max-width: 100%; max-height: 90px; margin-top: 8px; border-bottom: 1px solid var(--rule); }
.sig-overlay { position: fixed; inset: 0; z-index: 200; background: #fff; display: flex; flex-direction: column; gap: 12px; padding: 16px; padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
.sig-overlay canvas { flex: 1; width: 100%; min-height: 0; border: 2px dashed var(--rule); border-radius: 12px; background: #fff; touch-action: none; }
.sig-overlay .row { gap: 8px; align-items: center; }
.sig-overlay button { min-height: 46px; padding: 0 18px; }
@media (max-width: 960px) {
  .sign-panel { order: 0; }
  .sign-wrap { padding-bottom: 96px; }
  .sign-bar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; gap: 12px; align-items: center; justify-content: space-between;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid var(--rule); box-shadow: 0 -4px 16px rgba(20,30,50,.08); }
  .sign-bar span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .sign-bar button { min-height: 46px; padding: 0 22px; }
}
@media (max-width: 700px) {
  input, select, textarea { font-size: 16px; }
  .sign-wrap { padding: 10px 10px 96px; gap: 14px; }
  .sign-panel .panel { padding: 16px; }
  .primary.wide, button.wide, .btn.wide { min-height: 48px; }
  .check input[type=checkbox] { width: 22px; height: 22px; }
  .sign-top { padding: 10px 14px; }
  .center-box { padding: 24px 16px; }
  .codebox { font-size: 26px; letter-spacing: 8px; }
}

/* Organization branding */
.brand-row { display: flex; gap: 12px; align-items: center; min-width: 0; }
.brand-logo { max-height: 38px; max-width: 140px; object-fit: contain; flex: none; }
.side-logo { display: block; max-height: 40px; max-width: 170px; object-fit: contain; margin-bottom: 6px; }
.login-logo { display: block; max-height: 56px; max-width: 220px; object-fit: contain; margin: 0 auto 14px; }
