:root {
  --ink: #20242a; --muted: #6b7280; --line: #d9dde3; --bg: #f4f5f7;
  --brand: #1a5c4f; --brand-dark: #114439; --danger: #b3372f;
  --slot1: #1a5c4f; --slot2: #8a4b12; --slot3: #34437e; --slot4: #7a2f62;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: "Segoe UI", Arial, sans-serif; color: var(--ink); background: var(--bg); }
main { max-width: 1100px; margin: 0 auto; padding: 20px 16px 60px; }
.topbar { display: flex; justify-content: space-between; align-items: center; background: #fff; border-bottom: 1px solid var(--line); padding: 10px 18px; }
.topbar nav { display: flex; gap: 12px; align-items: center; }
.brand { font-weight: 700; color: var(--brand); text-decoration: none; font-size: 18px; }
.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 24px; }
h1 { font-size: 24px; } h2 { font-size: 17px; margin-top: 24px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 20px 24px; margin: 16px 0; }
.card.narrow { max-width: 560px; margin: 24px auto; }
.center { text-align: center; }
label { display: block; margin: 12px 0 4px; font-weight: 600; font-size: 14px; }
input[type=text], input[type=email], textarea, input[type=file] { width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 6px; font-size: 15px; font-family: inherit; }
.btn { display: inline-block; background: #fff; border: 1px solid var(--brand); color: var(--brand); padding: 9px 18px; border-radius: 6px; font-size: 15px; cursor: pointer; text-decoration: none; margin-top: 8px; }
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.small { padding: 5px 12px; font-size: 13px; margin-top: 0; }
.btn.danger { border-color: var(--danger); color: var(--danger); }
.btn.danger:hover, .btn.danger.primary { background: var(--danger); color: #fff; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.linklike { background: none; border: none; color: var(--muted); cursor: pointer; text-decoration: underline; font-size: 14px; }
.inline { display: inline; }
table.list { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: 10px; }
table.list th, table.list td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: top; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: 12px; background: #e6e8ec; text-transform: capitalize; }
.st-completed { background: #d7ecdf; color: #14532d; }
.st-sent, .st-viewed, .st-partial { background: #dbeafe; color: #1e3a5f; }
.st-declined, .st-voided, .st-expired { background: #fbe0de; color: #7f1d1d; }
.chip { display: inline-block; border: 1px solid var(--line); border-radius: 14px; padding: 1px 9px; font-size: 12px; margin: 1px; }
.chip.ok { border-color: #14532d; background: #d7ecdf; }
.hash { font-size: 11px; word-break: break-all; }
.error { color: var(--danger); font-weight: 600; }
.hint { color: var(--muted); font-size: 13px; }
.checkline { font-weight: 400; }
.checkline.big { font-size: 16px; margin: 18px 0; }
.checkline input { margin-right: 8px; }
blockquote { border-left: 3px solid var(--line); margin: 12px 0; padding: 4px 14px; color: var(--muted); }
.consent-text { font-size: 14px; color: #3a3f47; }
.rowform { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }

/* editor */
.editor-layout { display: flex; gap: 18px; align-items: flex-start; }
.panel { width: 320px; flex-shrink: 0; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 16px; position: sticky; top: 12px; max-height: calc(100vh - 40px); overflow-y: auto; }
.panel h2 { margin: 14px 0 6px; }
.pages { flex: 1; min-width: 0; }
.page-wrap { position: relative; margin: 0 auto 18px; box-shadow: 0 1px 6px rgba(0,0,0,0.15); background: #fff; }
.page-wrap img, .page-wrap canvas { display: block; width: 100%; height: auto; }
.fieldbtns { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.fieldbtns .btn.armed { background: var(--brand); color: #fff; }
.fbox { position: absolute; border: 2px solid var(--slot1); background: rgba(26,92,79,0.12); border-radius: 3px; cursor: move; font-size: 11px; color: var(--ink); overflow: hidden; }
.fbox .tag { position: absolute; top: 0; left: 0; background: rgba(255,255,255,0.85); padding: 0 4px; font-size: 10px; pointer-events: none; white-space: nowrap; }
.fbox.suggested { border-style: dashed; opacity: 0.8; }
.fbox.selected { outline: 3px solid #f2b705; }
.fbox.slot2 { border-color: var(--slot2); background: rgba(138,75,18,0.12); }
.fbox.slot3 { border-color: var(--slot3); background: rgba(52,67,126,0.12); }
.fbox.slot4 { border-color: var(--slot4); background: rgba(122,47,98,0.12); }
.fbox .resize { position: absolute; right: 0; bottom: 0; width: 12px; height: 12px; cursor: nwse-resize; background: linear-gradient(135deg, transparent 50%, rgba(0,0,0,0.4) 50%); }
.recipient-row { border: 1px solid var(--line); border-radius: 8px; padding: 8px; margin-bottom: 8px; }
.recipient-row input { margin-bottom: 4px; }
.recipient-row .slot-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 6px; }
#slot-picker { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
#slot-picker .slotbtn { border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px; font-size: 13px; cursor: pointer; background: #fff; }
#slot-picker .slotbtn.active { color: #fff; }
.actions { margin-top: 18px; display: flex; flex-direction: column; gap: 8px; }

/* signer */
.signbar { position: sticky; top: 0; z-index: 10; display: flex; justify-content: space-between; align-items: center; background: #fff; border-bottom: 1px solid var(--line); padding: 10px 14px; gap: 10px; flex-wrap: wrap; }
.pages.signer { max-width: 820px; margin: 16px auto; }
.sfield { position: absolute; border: 2px solid var(--brand); background: rgba(26,92,79,0.10); border-radius: 3px; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 12px; color: var(--brand); font-weight: 600; overflow: hidden; }
.sfield.filled { background: rgba(26,92,79,0.02); border-color: #9fb8b1; }
.sfield img { max-width: 100%; max-height: 100%; }
.sfield input { border: none; background: transparent; width: 100%; height: 100%; font-size: inherit; padding: 0 4px; }
.sfield.flash { outline: 3px solid #f2b705; }
dialog { border: 1px solid var(--line); border-radius: 10px; padding: 20px; max-width: 560px; width: 92%; }
dialog::backdrop { background: rgba(0,0,0,0.45); }
.tabs { display: flex; gap: 4px; margin-bottom: 10px; }
.tab { border: 1px solid var(--line); background: #fff; border-radius: 6px 6px 0 0; padding: 6px 14px; cursor: pointer; }
.tab.active { background: var(--brand); color: #fff; }
.tabpane.hidden, .hidden { display: none; }
#sig-canvas, #sig-typed-canvas { border: 1px dashed var(--line); border-radius: 6px; width: 100%; touch-action: none; }
.script-preview { font-family: "Segoe Script", "Brush Script MT", cursive; font-size: 34px; border: 1px dashed var(--line); border-radius: 6px; padding: 14px; min-height: 40px; }

@media (max-width: 760px) {
  .editor-layout { flex-direction: column; }
  .panel { width: 100%; position: static; max-height: none; }
  h1 { font-size: 20px; }
  .signbar div:last-child { display: flex; gap: 8px; align-items: center; }
}
