:root {
  --bg: #f4f5f8; --card: #fff; --ink: #1d2433; --muted: #667085; --line: #e3e6ec;
  --brand: #1f4fd1; --brand-ink: #fff; --danger: #c62828; --ok: #1b7f43; --warn: #b26a00;
  --c1: #d92d20; --c2: #1f4fd1; --c3: #12805c; --c4: #8a3ffc; --c5: #c4320a; --c0: #475467;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.55 "Segoe UI", "Noto Sans Hebrew", Arial, sans-serif; }
a { color: var(--brand); }
h1 { font-size: 1.35rem; margin: 0 0 .4rem; }
h2 { font-size: 1.05rem; margin: 0 0 .6rem; }
code, .mono { font-family: Consolas, "Courier New", monospace; font-size: .8rem; word-break: break-all; }
.hidden { display: none !important; }
.top { display: flex; align-items: center; gap: 1rem; justify-content: space-between; padding: .7rem 1rem;
  background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.top nav { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.top nav a { text-decoration: none; color: var(--ink); }
.brand { font-weight: 700; font-size: 1.1rem; text-decoration: none; color: var(--ink); }
.wrap { max-width: 1100px; margin: 1rem auto; padding: 0 16px; }
.wrap.wide { max-width: 1500px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; margin-bottom: 1rem; }
.card.narrow { max-width: 520px; margin-inline: auto; }
.card.notice { border-color: #f5c56b; background: #fffaf0; }
.center { text-align: center; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: .45rem; margin-top: .5rem; }
form.inline { display: inline; }
label { display: block; margin: .35rem 0; }
input, select, textarea { font: inherit; padding: .45rem .6rem; border: 1px solid #cfd4dc; border-radius: 8px; background: #fff; max-width: 100%; }
label input:not([type=checkbox]), label select { display: block; width: 100%; margin-top: .2rem; }
.btn { font: inherit; border: 1px solid #cfd4dc; background: #fff; color: var(--ink); padding: .5rem .9rem; border-radius: 8px;
  cursor: pointer; text-decoration: none; display: inline-block; }
.btn:hover { border-color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.danger { color: var(--danger); border-color: #f1b3b3; }
.btn.small { padding: .25rem .6rem; font-size: .88rem; }
.btn.wide { width: 100%; margin-bottom: .45rem; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.armed { outline: 3px solid #f5c56b; }
.link { background: none; border: 0; color: var(--brand); cursor: pointer; padding: 0; font: inherit; }
.hint { color: var(--muted); font-size: .85rem; }
.msgs { margin-bottom: 1rem; }
.msg { padding: .6rem .8rem; border-radius: 8px; margin-bottom: .4rem; background: #eef2ff; }
.msg.error { background: #fdecec; color: #8a1c1c; }
.msg.success { background: #e9f7ef; color: #135c32; }
.msg.info { background: #eef2ff; }
table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { text-align: start; padding: .45rem .4rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list.small { font-size: .85rem; }
.scroll { overflow-x: auto; }
.st { display: inline-block; padding: .05rem .5rem; border-radius: 99px; font-size: .78rem; background: #eef0f4; }
.st-draft, .st-pending { background: #eef0f4; }
.st-sent, .st-viewed { background: #fff4e0; color: #8a5300; }
.st-completed, .st-signed { background: #e3f5ea; color: #135c32; }
.st-declined, .st-cancelled { background: #fdecec; color: #8a1c1c; }
.checks { list-style: none; padding: 0; margin: 0; }
.checks li { padding: .3rem .5rem .3rem 0; border-bottom: 1px dashed var(--line); font-size: .88rem; }
.checks li::before { margin-inline-end: .35rem; }
.lvl-ok::before { content: "✓"; color: var(--ok); }
.lvl-error { color: #8a1c1c; } .lvl-error::before { content: "✗"; }
.lvl-warn { color: #7a4a00; } .lvl-warn::before { content: "⚠"; }
.lvl-info { color: var(--muted); } .lvl-info::before { content: "ℹ"; }
.linkrow { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin: .3rem 0; }
input.copy { flex: 1; min-width: 240px; font-family: Consolas, monospace; font-size: .8rem; }
.cols { display: grid; grid-template-columns: 330px 1fr; gap: 1rem; align-items: start; }
.side { position: sticky; top: 4rem; max-height: calc(100vh - 5rem); overflow: auto; }
.signer { padding: .45rem 0; border-bottom: 1px solid var(--line); }
.dot { display: inline-block; width: .7rem; height: .7rem; border-radius: 50%; margin-inline-end: .3rem; background: var(--c0); }
.dot.c1 { background: var(--c1); } .dot.c2 { background: var(--c2); } .dot.c3 { background: var(--c3); }
.dot.c4 { background: var(--c4); } .dot.c5 { background: var(--c5); }
/* pages + fields */
.pages { display: flex; flex-direction: column; gap: 14px; align-items: center; }
.page { position: relative; width: 100%; max-width: 900px; box-shadow: 0 1px 4px rgba(0,0,0,.15); background: #fff; user-select: none; touch-action: pan-y; }
.page img { display: block; width: 100%; height: auto; pointer-events: none; }
.pno { position: absolute; bottom: 4px; left: 8px; font-size: .75rem; color: var(--muted); }
.fld { position: absolute; border: 2px solid var(--c0); background: rgba(71,84,103,.10); border-radius: 4px; font-size: 11px;
  color: var(--c0); overflow: visible; }
.fld .tag { position: absolute; top: -17px; right: 0; white-space: nowrap; background: inherit; padding: 0 4px; border-radius: 3px; }
.fld.s1 { border-color: var(--c1); color: var(--c1); background: rgba(217,45,32,.10); }
.fld.s2 { border-color: var(--c2); color: var(--c2); background: rgba(31,79,209,.10); }
.fld.s3 { border-color: var(--c3); color: var(--c3); background: rgba(18,128,92,.10); }
.fld.s4 { border-color: var(--c4); color: var(--c4); background: rgba(138,63,252,.10); }
.fld.s5 { border-color: var(--c5); color: var(--c5); background: rgba(196,50,10,.10); }
.fld.low { border-style: dashed; }
.fld.sel { box-shadow: 0 0 0 3px #f5c56b; }
.editable .fld { cursor: move; touch-action: none; }
.fld .rs { position: absolute; left: -6px; bottom: -6px; width: 12px; height: 12px; background: #fff; border: 2px solid currentColor; border-radius: 3px; cursor: nesw-resize; }
.pages.adding .page { cursor: crosshair; }
.fieldpanel { display: flex; gap: .7rem; align-items: end; flex-wrap: wrap; background: #fffaf0; border: 1px solid #f5c56b;
  border-radius: 8px; padding: .5rem .7rem; margin: .5rem 0; }
.fieldpanel label { margin: 0; }
/* signer page */
body.signer .wrap.sign { max-width: 920px; padding-bottom: 90px; }
.consent { display: flex; gap: .6rem; align-items: flex-start; background: #f6f8ff; border: 1px solid #d9e1ff; border-radius: 8px; padding: .7rem; margin: .8rem 0; }
.consent input { margin-top: .25rem; transform: scale(1.3); }
.decline { margin-top: 1rem; color: var(--muted); }
.sf { position: absolute; border: 2px dashed var(--c1); background: rgba(255,214,0,.28); border-radius: 4px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: 12px; color: #6b4e00; font-weight: 600; touch-action: manipulation; }
.sf.done { border-style: solid; border-color: var(--ok); background: rgba(27,127,67,.06); }
.sf img { max-width: 100%; max-height: 100%; }
.sf input { width: 100%; height: 100%; border: 0; background: transparent; font-size: 13px; padding: 0 4px; }
.sf.static { cursor: default; }
.sf.cb { padding: 0; font-size: 0; border-width: 2px; border-radius: 2px; }
.sf.cb::before { content: ""; position: absolute; inset: -12px; }  /* finger-sized hit area around a 10pt box */
.sf.cb.done { border-style: solid; border-color: var(--brand); background: var(--brand); }
.sf.cb.done::after { content: "✓"; color: #fff; font-size: 12px; line-height: 1; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.sf.cb.opt { border-color: var(--brand); background: rgba(31,79,209,.12); }
.signbar { position: fixed; bottom: 0; left: 0; right: 0; background: var(--card); border-top: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: center; gap: .6rem; padding: .7rem 16px; z-index: 30; }
.modal { position: fixed; inset: 0; background: rgba(16,24,40,.55); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 12px; }
.modal-box { background: #fff; border-radius: 12px; padding: 1rem; width: min(640px, 100%); }
#canvas { width: 100%; height: auto; aspect-ratio: 600 / 220; border: 1px dashed #98a2b3; border-radius: 8px; background: #fff; touch-action: none; display: block; margin: .5rem 0; }
@media (max-width: 900px) {
  .cols { grid-template-columns: 1fr; }
  .side { position: static; max-height: none; }
  .top nav { gap: .6rem; font-size: .9rem; }
}
