:root {
  --green: #0b5d4b; --green-dark: #094b3d; --green-soft: #e7f2ef;
  --gold: #f2b705; --ink: #1d2433; --muted: #5f6b7a; --line: #dfe4ea;
  --bg: #f4f6f8; --panel: #ffffff; --danger: #a3261d;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.45 "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
button, input, select { font: inherit; }
.topbar { height: 56px; display: flex; align-items: center; gap: 12px; padding: 0 20px;
  background: var(--green); color: #fff; position: sticky; top: 0; z-index: 20; }
.topbar .brand { font-weight: 700; letter-spacing: .2px; display: flex; align-items: center; gap: 8px; }
.topbar .brand img { width: 24px; height: 24px; }
.topbar .file { margin-left: 8px; opacity: .9; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .spacer { flex: 1; }
.badge { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 10px; background: rgba(255,255,255,.18); text-transform: uppercase; }

.btn { border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 8px;
  padding: 9px 14px; cursor: pointer; font-weight: 600; }
.btn:hover { border-color: #c4ccd5; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-dark); }
.btn-gold { background: var(--gold); border-color: var(--gold); color: #1d2433; }
.btn-link { background: none; border: 0; color: var(--green); padding: 0; cursor: pointer; font-weight: 600; text-decoration: underline; }
.btn-block { width: 100%; }
.btn:focus-visible, .chip:focus-visible, input:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.layout { display: grid; grid-template-columns: 340px 1fr; gap: 0; min-height: calc(100vh - 56px); }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 18px; position: sticky; top: 56px;
  height: calc(100vh - 56px); overflow: auto; display: flex; flex-direction: column; gap: 16px; }
.main { padding: 24px; overflow: auto; }
.section h3 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.hint { color: var(--muted); font-size: 13px; margin: 0; }
.sigpreview { border: 1px dashed var(--line); border-radius: var(--radius); height: 90px; display: flex;
  align-items: center; justify-content: center; background: repeating-conic-gradient(#fafbfc 0 25%, #f1f3f5 0 50%) 0 0/16px 16px; }
.sigpreview img { max-height: 76px; max-width: 90%; }

.rotbar { display: flex; gap: 6px; margin-bottom: 6px; }
.btn-sm { padding: 6px 10px; font-size: 13px; }
.rotval { min-width: 42px; text-align: right; font-variant-numeric: tabular-nums; }
.spots { display: flex; flex-direction: column; gap: 8px; }
.spot { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; cursor: pointer; background: #fff; }
.spot:hover { border-color: #b9c3cd; }
.spot.on { border-color: var(--green); background: var(--green-soft); }
.spot input { margin-top: 3px; accent-color: var(--green); }
.spot .t { font-weight: 600; }
.spot .s { color: var(--muted); font-size: 12.5px; }

.range { display: flex; align-items: center; gap: 10px; }
.range input { flex: 1; accent-color: var(--green); }
.check { display: flex; gap: 8px; align-items: center; cursor: pointer; }
[hidden] { display: none !important; }
.check input { accent-color: var(--green); }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; }
.field { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; background: #fff; }

.actions { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.status { font-size: 13px; min-height: 18px; }
.status.err { color: var(--danger); }
.status.ok { color: var(--green); }

.banner { background: #fff8e1; border: 1px solid #f3dd8f; border-radius: var(--radius); padding: 12px 14px; }

/* PDF pages */
.pages { display: flex; flex-direction: column; align-items: center; gap: 18px; }
.page { position: relative; background: #fff; box-shadow: 0 2px 10px rgba(16,24,40,.12); }
.page canvas { display: block; }
.page .overlay { position: absolute; inset: 0; cursor: crosshair; }
.page .pno { position: absolute; top: -18px; left: 0; font-size: 12px; color: var(--muted); }
.placed { position: absolute; cursor: move; touch-action: none; outline: 1px dashed rgba(11,93,75,.6); outline-offset: 2px; }
.placed img { display: block; width: 100%; height: 100%; pointer-events: none; user-select: none; }
.placed .x { position: absolute; top: -10px; right: -10px; width: 20px; height: 20px; border-radius: 50%;
  border: 0; background: var(--danger); color: #fff; font-size: 12px; line-height: 20px; padding: 0; cursor: pointer; display: none; }
.placed:hover .x { display: block; }
.placed .dt { position: absolute; left: 100%; bottom: 0; margin-left: 4px; font: 8px Helvetica, Arial, sans-serif; white-space: nowrap; color: #1a1a1a; }

/* Office card */
.doccard { max-width: 760px; margin: 0 auto; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 28px; }
.doccard h2 { margin: 0 0 6px; font-size: 20px; }
.doccard .icon { font-size: 34px; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

.drop { max-width: 620px; margin: 40px auto; border: 2px dashed #b7c2cc; border-radius: 16px; background: #fff;
  padding: 50px 24px; text-align: center; }
.drop.over { border-color: var(--green); background: var(--green-soft); }
.drop h2 { margin: 0 0 8px; }

.done { max-width: 520px; margin: 80px auto; text-align: center; background: #fff; border-radius: 16px; padding: 40px;
  border: 1px solid var(--line); }
.done .big { font-size: 46px; }

/* v2: signature + stamp */
.assets { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.asset { border: 1px solid var(--line); border-radius: 8px; padding: 8px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.asset-h { display: flex; justify-content: space-between; align-items: center; font-size: 13px; }
.asset-empty { justify-content: center; align-items: flex-start; background: #fafbfc; }
.sigpreview.small { height: 64px; }
.sigpreview.small img { max-height: 54px; }
.asset .rotbar .btn-sm { padding: 4px 8px; }
.asset .range input { min-width: 0; }
.tiny { font-size: 12px; }
.chips { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 14px; padding: 4px 10px; font-size: 12.5px; font-weight: 600; cursor: pointer; color: var(--muted); }
.chip.on { background: var(--green); border-color: var(--green); color: #fff; }
.chip:disabled { opacity: .45; cursor: default; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg-b { border: 0; background: #fff; padding: 6px 12px; cursor: pointer; font-weight: 600; color: var(--muted); }
.seg-b + .seg-b { border-left: 1px solid var(--line); }
.seg-b.on { background: var(--green); color: #fff; }
.spot-body { flex: 1; min-width: 0; }
.mt8 { margin-top: 8px; }
.mt14 { margin-top: 14px; }
.placed-stamp { outline-color: rgba(242,183,5,.8); }

/* v2: editor */
.ed-wrap { display: flex; flex-direction: column; height: calc(100vh - 56px); }
.ed-bar { display: flex; gap: 8px; align-items: center; padding: 8px 14px; background: #fff; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.ed-bar .field { width: auto; }
.ed-ref { width: 80px !important; font-weight: 700; text-align: center; }
.ed-fx { flex: 1; min-width: 200px; font-family: Consolas, "Courier New", monospace; }
.ed-tabs { display: flex; gap: 2px; padding: 0 14px; background: #eef1f4; border-top: 1px solid var(--line); overflow-x: auto; }
.ed-tab { border: 0; background: transparent; padding: 7px 14px; cursor: pointer; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; white-space: nowrap; }
.ed-tab.on { background: #fff; color: var(--green); border-bottom-color: var(--green); }
.ed-grid { flex: 1; min-height: 0; overflow: auto; background: #e9ecef; position: relative; }
table.xl { border-collapse: collapse; table-layout: fixed; background: #fff; font: 11pt Calibri, Carlito, Arial, sans-serif; }
table.xl td, table.xl th { border: 1px solid #e3e6e9; padding: 1px 3px; overflow: hidden; white-space: nowrap; vertical-align: bottom; position: relative; }
table.xl th { background: #f3f5f7; color: #5f6b7a; font: 600 11px "Segoe UI", Arial, sans-serif; text-align: center; position: sticky; z-index: 2; }
table.xl thead th { top: 0; }
table.xl th.rh { left: 0; z-index: 3; }
table.xl thead th.rh { z-index: 4; }
table.xl td.wrap { white-space: normal; word-wrap: break-word; }
table.xl td.sel { outline: 2px solid var(--green); outline-offset: -2px; z-index: 1; }
table.xl td.chg { background-image: linear-gradient(135deg, var(--gold) 0 6px, transparent 6px); }
table.xl td input.ed-in { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; padding: 1px 3px; font: inherit; outline: 2px solid var(--gold); background: #fffef5; z-index: 5; }
.xl-img { position: absolute; pointer-events: none; z-index: 1; }
.ed-legend { font-size: 12px; color: var(--muted); }
.doc-ed { max-width: 860px; margin: 0 auto; background: #fff; box-shadow: 0 2px 10px rgba(16,24,40,.12); padding: 48px 56px; font: 11pt Calibri, Carlito, Arial, sans-serif; }
.doc-p { min-height: 1.3em; padding: 2px 4px; border-radius: 4px; white-space: pre-wrap; }
.doc-p[contenteditable="true"]:hover { background: #f6faf9; }
.doc-p[contenteditable="true"]:focus { outline: 2px solid var(--gold); background: #fffef5; }
.doc-p.chg { box-shadow: inset 3px 0 0 var(--gold); }
.doc-p.ro { color: #5f6b7a; font-style: italic; }
.doc-t { border-collapse: collapse; width: 100%; margin: 6px 0; }
.doc-t td { border: 1px solid #c9d1d9; vertical-align: top; padding: 2px; }
.doc-h1 { font-size: 16pt; font-weight: 700; }
.doc-h2 { font-size: 13pt; font-weight: 700; }

/* v2.1: editor with in-sheet signing */
.ed-bar2 { padding-top: 6px; padding-bottom: 6px; background: #fafbfc; }
.ed-body { flex: 1; display: flex; min-height: 0; }
.ed-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ed-side { width: 330px; flex: none; background: #fff; border-left: 1px solid var(--line); overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.ed-side[hidden] { display: none; }
.btn-gold.on { box-shadow: inset 0 0 0 2px #1d2433; }
.xl-holder { position: relative; display: inline-block; }
table.xl td.insel { background-color: rgba(11,93,75,.10) !important; }
.xl-place { position: absolute; z-index: 6; cursor: move; touch-action: none; outline: 1px dashed rgba(11,93,75,.7); outline-offset: 1px; }
.xl-place-stamp { outline-color: rgba(242,183,5,.9); }
.xl-place img { display: block; width: 100%; height: 100%; pointer-events: none; user-select: none; }
.xl-place .x { position: absolute; top: -10px; right: -10px; width: 20px; height: 20px; border-radius: 50%; border: 0; background: var(--danger); color: #fff;
  font-size: 12px; line-height: 20px; padding: 0; cursor: pointer; display: none; }
.xl-place:hover .x, .xl-place:focus-within .x { display: block; }
.xl-place .rz { position: absolute; right: -5px; bottom: -5px; width: 10px; height: 10px; background: var(--green); border: 2px solid #fff; border-radius: 2px; cursor: nwse-resize; display: none; }
.xl-place:hover .rz { display: block; }
.dt-place { position: absolute; cursor: move; touch-action: none; white-space: nowrap; font-family: Helvetica, Arial, sans-serif; color: #141418; outline: 1px dashed rgba(26,86,168,.7); outline-offset: 2px; line-height: 1; }
.dt-place .x { position: absolute; top: -12px; right: -12px; width: 18px; height: 18px; border-radius: 50%; border: 0; background: var(--danger); color: #fff; font-size: 11px; line-height: 18px; padding: 0; cursor: pointer; display: none; }
.dt-place:hover .x { display: block; }

/* v2.2: PDF tools */
.pg-board { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; align-content: start; }
.pg { position: relative; background: #fff; border: 2px solid transparent; border-radius: 10px; padding: 8px; box-shadow: 0 1px 4px rgba(16,24,40,.12); cursor: grab; user-select: none; }
.pg.dragging { opacity: .4; }
.pg.drop-before { box-shadow: -4px 0 0 var(--gold), 0 1px 4px rgba(16,24,40,.12); }
.pg.drop-after { box-shadow: 4px 0 0 var(--gold), 0 1px 4px rgba(16,24,40,.12); }
.pg.sel { border-color: var(--green); background: var(--green-soft); }
.pg .thumb { height: 180px; display: flex; align-items: center; justify-content: center; background: #f4f6f8; border-radius: 6px; overflow: hidden; }
.pg .thumb canvas { max-width: 100%; max-height: 100%; box-shadow: 0 0 0 1px #dfe4ea; transition: transform .15s; }
.pg .no { position: absolute; top: 4px; left: 4px; background: var(--green); color: #fff; font-weight: 700; font-size: 12px; border-radius: 10px; padding: 2px 8px; z-index: 1; }
.pg .src { font-size: 11.5px; color: var(--muted); margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pg .tools { display: flex; gap: 4px; margin-top: 6px; flex-wrap: wrap; }
.pg .tools button { border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 3px 7px; cursor: pointer; font-size: 12px; }
.pg .tools button:hover { border-color: #b9c3cd; }
.pg .tools .del { color: var(--danger); }
.pg .ck { position: absolute; top: 6px; right: 6px; width: 18px; height: 18px; accent-color: var(--green); z-index: 1; }
.doclist { display: flex; flex-direction: column; gap: 6px; }
.docrow { display: flex; gap: 8px; align-items: center; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; }
.docrow .sw { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.docrow .n { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.docrow button { border: 0; background: none; cursor: pointer; color: var(--muted); padding: 2px 4px; }
.radio { display: flex; gap: 8px; align-items: flex-start; margin: 6px 0; cursor: pointer; }
.radio input { accent-color: var(--green); margin-top: 3px; }
.outlist { font-size: 12.5px; color: var(--muted); margin: 6px 0 0; padding-left: 18px; max-height: 140px; overflow: auto; }
.pick { border: 1px solid var(--line); border-radius: 8px; max-height: 200px; overflow: auto; }
.pick label { display: flex; gap: 8px; padding: 6px 8px; font-size: 13px; cursor: pointer; border-bottom: 1px solid var(--line); }
.pick label:last-child { border-bottom: 0; }

/* opened from an older file format (3.3.1) */
.ed-note { background: #fff7d6; border-bottom: 1px solid #f0e3b6; color: #3b3214; padding: 8px 16px; font-size: 13.5px; }
/* Word: signatures, stamps and dates placed in the document (3.3.0) */
.doc-p.sel { background: #fffbea; box-shadow: inset 3px 0 0 var(--gold, #d4af37); }
.doc-p.ro[tabindex] { cursor: pointer; }
.doc-sigs { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; padding: 2px 4px 4px; }
.doc-sigs[hidden] { display: none; }
.doc-sig { position: relative; display: inline-flex; align-items: flex-end; gap: 4px; outline: 1px dashed rgba(11,93,75,.7); outline-offset: 2px; border-radius: 2px; }
.doc-sig-stamp { outline-color: rgba(212,175,55,.95); }
.doc-sig img { display: block; user-select: none; }
.doc-date { font: inherit; padding: 1px 6px; background: #f3faf6; }
.doc-sig .mini { border: 1px solid var(--line); background: #fff; border-radius: 6px; font-size: 12px; line-height: 1; padding: 3px 6px; cursor: pointer; }
.doc-sig .mini:hover { border-color: var(--green); }
.doc-sig-tools { display: inline-flex; flex-direction: column; gap: 2px; }
.doc-sig .x { color: var(--danger); align-self: flex-start; }

/* ===================== 3.4.0: tools on top of every signing screen ===================== */
.sd-wrap { display: flex; flex-direction: column; height: calc(100vh - 56px); }
.sd-top { position: sticky; top: 56px; z-index: 15; background: #fff; border-bottom: 1px solid var(--line); box-shadow: 0 2px 6px rgba(16,24,40,.06); }
.sd-tools { display: flex; align-items: center; gap: 10px; padding: 8px 14px; flex-wrap: wrap; }
.sd-group { display: flex; align-items: center; gap: 6px; }
.sd-group + .sd-group { padding-left: 10px; border-left: 1px solid var(--line); }
.sd-flex { flex: 1; }
.sd-tool { border: 2px solid var(--line); background: #fff; color: var(--ink); border-radius: 10px; padding: 9px 14px; font-weight: 700; font-size: 14.5px; cursor: pointer; white-space: nowrap; }
.sd-tool:hover { border-color: var(--green); }
.sd-tool.on { background: var(--green); border-color: var(--green); color: #fff; box-shadow: 0 2px 6px rgba(11,93,75,.3); }
.sd-tool-date.on { background: #1a56a8; border-color: #1a56a8; }
.sd-tool.sd-missing { opacity: .5; }
.sd-tool:focus-visible, .sd-act:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.sd-date { display: inline-flex; align-items: center; gap: 4px; position: relative; }
.sd-date-in { width: 128px; font-weight: 600; font-size: 14.5px; padding: 8px 10px; }
.sd-date-cal { padding: 7px 9px; }
.sd-date-pick { position: absolute; right: 0; bottom: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; border: 0; padding: 0; }
.sd-lbl { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.sd-turn { padding: 6px 9px; }
.sd-hint { font-size: 13px; color: var(--muted); }
.sd-acts { gap: 8px; }
.sd-act { white-space: nowrap; }
.sd-act-sm { padding: 8px 10px; font-size: 13px; }
.sd-status { padding: 0 14px 8px; }
.sd-status:empty { display: none; }
.sd-banner { margin: 10px 14px 0; }
.sd-main { flex: 1; overflow: auto; }
@media (max-width: 900px) { .sd-group + .sd-group { border-left: 0; padding-left: 0; } .sd-acts { width: 100%; } .sd-acts .sd-act { flex: 1; } }

/* every placed item can be resized: － ＋ buttons and a corner handle */
.placed .rz, .dt-place .rz { position: absolute; right: -6px; bottom: -6px; width: 12px; height: 12px; background: var(--green); border: 2px solid #fff; border-radius: 3px; cursor: nwse-resize; display: none; box-shadow: 0 0 0 1px rgba(0,0,0,.15); }
.dt-place .rz { background: #1a56a8; }
.ptools { position: absolute; left: 0; top: -26px; display: none; gap: 3px; white-space: nowrap; }
.ptools .sz { border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 6px; font-size: 13px; line-height: 1; width: 22px; height: 22px; padding: 0; cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.ptools .sz:hover { border-color: var(--green); }
.xl-place:hover .ptools, .xl-place:focus-within .ptools,
.placed:hover .rz, .placed:hover .ptools, .placed:focus-within .ptools,
.dt-place:hover .rz, .dt-place:hover .ptools, .dt-place:focus-within .ptools { display: flex; }
.placed:hover .rz, .dt-place:hover .rz { display: block; }
.dt-edit { font: inherit; width: 9em; border: 1px solid #1a56a8; border-radius: 3px; padding: 0 2px; }
.ptools::after { content: ''; position: absolute; left: 0; right: 0; top: 100%; height: 6px; }

/* editor zoom (3.4.0) */
.zoombar { display: inline-flex; align-items: center; gap: 4px; }
.zoombar .zv { min-width: 46px; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; font-size: 13px; }

/* 3.4.0: redact */
.rd-overlay { cursor: crosshair; }
.rd-box { position: absolute; background: #000; outline: 2px solid #a3261d; outline-offset: 1px; }
.rd-ghost { background: rgba(0,0,0,.55); outline-style: dashed; }
.rd-box .x { position: absolute; top: -10px; right: -10px; width: 20px; height: 20px; border-radius: 50%; border: 0; background: var(--danger); color: #fff; font-size: 12px; line-height: 20px; padding: 0; cursor: pointer; display: none; }
.rd-box:hover .x { display: block; }
/* inside the SignDesk window in Gmail: the window has its own title bar, so the page header is smaller */
html.sd-embedded .topbar { height: 44px; }
html.sd-embedded .sd-top { top: 44px; }
html.sd-embedded .sd-wrap, html.sd-embedded .ed-wrap { height: calc(100vh - 44px); }

.xl-place-date { outline-color: rgba(26,86,168,.7); }
