/* Juarain Sign — mobile-first styles. No framework, no web fonts: fast on any phone. */

:root {
  --brand: #d9141b;
  --brand-600: #b40f15;
  --brand-50: #fff1f0;
  --brand-100: #ffe0dd;
  --orange: #f26b1d;
  --gold: #f9a51a;
  --ink: #16171b;
  --ink-2: #3b3e46;
  --muted: #646a76;
  --line: #e5e6ea;
  --line-2: #eff0f3;
  --bg: #f6f6f8;
  --card: #ffffff;
  --blue: #1f5fd6;
  --blue-50: #ebf2ff;
  --green: #12805c;
  --green-50: #e7f6ef;
  --amber: #a15c00;
  --amber-50: #fff4e0;
  --red: #c4161c;
  --red-50: #fdecec;
  --gray-50: #f1f2f4;
  --first: #d9141b;   /* Juarain areas */
  --second: #1f5fd6;  /* EO areas */
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16, 17, 20, .05), 0 4px 16px rgba(16, 17, 20, .05);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --tap: 48px;
  --nav-h: 64px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 16px; line-height: 1.5; color: var(--ink);
  background: var(--bg); overflow-x: hidden; -webkit-font-smoothing: antialiased;
}
img, svg, canvas { max-width: 100%; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; letter-spacing: -.01em; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
.ic { flex-shrink: 0; vertical-align: middle; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.xs { font-size: .78rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .82rem; word-break: break-all; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.break { overflow-wrap: anywhere; }

/* ---------- layout ---------- */
.container { width: 100%; max-width: 960px; margin: 0 auto; padding: 16px; }
.narrow { max-width: 560px; }
.stack > * + * { margin-top: 16px; }
.stack-sm > * + * { margin-top: 10px; }
.row { display: flex; gap: 12px; align-items: center; }
.row-wrap { display: flex; flex-wrap: wrap; gap: 8px; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.grid-2 { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 720px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

/* ---------- top bar & nav ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30; background: rgba(255, 255, 255, .96);
  border-bottom: 1px solid var(--line); backdrop-filter: saturate(1.4) blur(6px);
}
.topbar-in { max-width: 960px; margin: 0 auto; height: 60px; padding: 0 16px; display: flex; align-items: center; gap: 12px; }
.logo { display: inline-flex; align-items: center; }
.logo img { height: 34px; width: auto; display: block; }
.topnav { display: none; margin-left: 12px; gap: 4px; }
.topnav a { padding: 8px 12px; border-radius: 999px; color: var(--ink-2); font-weight: 600; font-size: .92rem; }
.topnav a:hover { background: var(--gray-50); text-decoration: none; }
.topnav a.on { background: var(--brand-50); color: var(--brand); }
.topbar .spacer { flex: 1; }
.iconbtn {
  display: inline-flex; align-items: center; justify-content: center; width: 42px; height: 42px;
  border-radius: 50%; border: 0; background: transparent; color: var(--ink-2); cursor: pointer;
}
.iconbtn:hover { background: var(--gray-50); }

.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom); background: #fff; border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(4, 1fr);
}
.bottomnav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); font-size: .72rem; font-weight: 600; text-decoration: none;
}
.bottomnav a.on { color: var(--brand); }
.bottomnav .fab span.ring {
  width: 44px; height: 44px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: var(--brand); color: #fff; box-shadow: 0 4px 12px rgba(217, 20, 27, .35); margin-top: -10px;
}
body.has-bottomnav main { padding-bottom: calc(var(--nav-h) + 24px + env(safe-area-inset-bottom)); }
@media (min-width: 820px) {
  .topnav { display: flex; }
  .bottomnav { display: none; }
  body.has-bottomnav main { padding-bottom: 40px; }
}

/* ---------- cards ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 16px; }
@media (min-width: 720px) { .card-pad { padding: 20px; } }
.card-head { padding: 14px 16px; border-bottom: 1px solid var(--line-2); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card-head h2, .card-head h3 { margin: 0; font-size: 1rem; }
.card-body { padding: 16px; }
.section-title { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; margin: 0 0 8px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--tap);
  padding: 0 18px; border-radius: 12px; border: 1px solid transparent; font: inherit; font-weight: 700;
  font-size: 1rem; cursor: pointer; text-decoration: none !important; transition: background .15s, box-shadow .15s, transform .05s;
  -webkit-tap-highlight-color: transparent; user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 2px 8px rgba(217, 20, 27, .25); }
.btn-primary:hover { background: var(--brand-600); }
.btn-dark { background: var(--ink); color: #fff; }
.btn-light { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-light:hover { background: var(--gray-50); }
.btn-soft { background: var(--brand-50); color: var(--brand); }
.btn-soft:hover { background: var(--brand-100); }
.btn-blue { background: var(--blue); color: #fff; }
.btn-green { background: #128c4b; color: #fff; }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--gray-50); }
.btn-danger { background: #fff; color: var(--red); border-color: #f3c7c8; }
.btn-danger:hover { background: var(--red-50); }
.btn-block { width: 100%; }
.btn-lg { min-height: 56px; font-size: 1.05rem; border-radius: 14px; }
.btn-sm { min-height: 38px; padding: 0 12px; font-size: .9rem; border-radius: 10px; }
.btn[disabled], .btn.is-loading { opacity: .6; pointer-events: none; }
.btn .spin { width: 18px; height: 18px; border: 2.5px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.actions { display: flex; flex-direction: column; gap: 10px; }
@media (min-width: 560px) { .actions { flex-direction: row; flex-wrap: wrap; } }

/* ---------- forms ---------- */
.field { display: block; }
.field + .field { margin-top: 14px; }
.label { display: block; font-weight: 700; font-size: .92rem; margin-bottom: 6px; }
.label .opt { font-weight: 500; color: var(--muted); }
.hint { font-size: .82rem; color: var(--muted); margin-top: 5px; }
.input, .select, .textarea {
  width: 100%; min-height: var(--tap); padding: 11px 14px; border: 1.5px solid var(--line); border-radius: 12px;
  font: inherit; font-size: 16px; color: var(--ink); background: #fff; transition: border-color .15s, box-shadow .15s;
}
.textarea { min-height: 88px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px rgba(217, 20, 27, .12); }
.check { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
.check input { width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--brand); flex-shrink: 0; }

.choice { display: grid; gap: 10px; }
.choice label {
  display: flex; gap: 12px; align-items: flex-start; padding: 14px; border: 1.5px solid var(--line);
  border-radius: 12px; cursor: pointer; background: #fff;
}
.choice input { width: 20px; height: 20px; accent-color: var(--brand); margin: 2px 0 0; flex-shrink: 0; }
.choice label:has(input:checked) { border-color: var(--brand); background: var(--brand-50); }
.choice b { display: block; }
.choice .small { display: block; }

.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pills label { position: relative; }
.pills input { position: absolute; opacity: 0; inset: 0; }
.pills span {
  display: inline-flex; align-items: center; min-height: 42px; padding: 0 14px; border: 1.5px solid var(--line);
  border-radius: 999px; font-weight: 600; font-size: .92rem; cursor: pointer; background: #fff;
}
.pills input:checked + span { border-color: var(--brand); background: var(--brand-50); color: var(--brand); }
.pills input:focus-visible + span { box-shadow: 0 0 0 3px rgba(217, 20, 27, .25); }

.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 6px;
  padding: 26px 16px; border: 2px dashed #d7d9de; border-radius: var(--radius); background: #fff; cursor: pointer;
}
.dropzone.drag, .dropzone:hover { border-color: var(--brand); background: var(--brand-50); }
.dropzone .dz-icon { width: 52px; height: 52px; border-radius: 14px; background: var(--brand-50); color: var(--brand); display: flex; align-items: center; justify-content: center; }
.dropzone.has-file { border-style: solid; border-color: #b9e1cf; background: var(--green-50); }
.dropzone.has-file .dz-icon { background: #fff; color: var(--green); }
.dropzone input { display: none; }

.progress { height: 8px; border-radius: 999px; background: var(--line-2); overflow: hidden; }
.progress > i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--brand), var(--orange)); transition: width .2s; }

/* ---------- alerts & badges ---------- */
.alert { display: flex; gap: 10px; padding: 12px 14px; border-radius: 12px; font-size: .94rem; border: 1px solid; align-items: flex-start; }
.alert .ic { margin-top: 2px; }
.alert-success { background: var(--green-50); color: #0b5a40; border-color: #bfe5d4; }
.alert-error { background: var(--red-50); color: #8f1015; border-color: #f4c4c6; }
.alert-info { background: var(--blue-50); color: #17448f; border-color: #c9dbfb; }
.alert-warn { background: var(--amber-50); color: #7a4600; border-color: #f6dcaa; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: .76rem; font-weight: 700; white-space: nowrap; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge-gray { background: var(--gray-50); color: #555b66; }
.badge-amber { background: var(--amber-50); color: var(--amber); }
.badge-blue { background: var(--blue-50); color: var(--blue); }
.badge-green { background: var(--green-50); color: var(--green); }
.badge-red { background: var(--red-50); color: var(--red); }
.tag-new { background: var(--brand); color: #fff; border-radius: 999px; font-size: .7rem; font-weight: 800; padding: 2px 8px; }

/* ---------- dashboard ---------- */
.hello { padding: 4px 0 2px; }
.hello h1 { margin: 0; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (min-width: 720px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { display: block; padding: 14px; border-radius: var(--radius); background: #fff; border: 1px solid var(--line); color: var(--ink); text-decoration: none !important; }
.stat:hover { border-color: #d3d5da; }
.stat .n { font-size: 1.7rem; font-weight: 800; line-height: 1.1; }
.stat .l { font-size: .84rem; color: var(--muted); font-weight: 600; }
.stat.s-wait .n { color: var(--blue); }
.stat.s-done .n { color: var(--green); }
.stat.s-exp .n { color: var(--red); }

.cta {
  display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: var(--radius); color: #fff !important;
  background: linear-gradient(120deg, var(--brand) 0%, #e8371b 55%, var(--orange) 100%); text-decoration: none !important;
  box-shadow: 0 6px 20px rgba(217, 20, 27, .25);
}
.cta .ci { width: 46px; height: 46px; border-radius: 12px; background: rgba(255, 255, 255, .18); display: flex; align-items: center; justify-content: center; }
.cta b { display: block; font-size: 1.05rem; }
.cta span { font-size: .88rem; opacity: .92; }

.list { list-style: none; margin: 0; padding: 0; }
.list > li + li { border-top: 1px solid var(--line-2); }
.doc-item { display: flex; gap: 12px; align-items: center; padding: 14px 16px; color: var(--ink); text-decoration: none !important; }
.doc-item:hover { background: #fafafb; }
.doc-item .di { width: 40px; height: 40px; border-radius: 10px; background: var(--gray-50); color: var(--ink-2); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.doc-item .t { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-item .s { font-size: .84rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-item .meta { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin-top: 4px; }
.empty { text-align: center; padding: 32px 16px; color: var(--muted); }
.empty .ei { width: 56px; height: 56px; margin: 0 auto 10px; border-radius: 16px; background: var(--gray-50); display: flex; align-items: center; justify-content: center; color: #8a8f99; }

.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.filters a { padding: 7px 12px; border-radius: 999px; background: #fff; border: 1px solid var(--line); color: var(--ink-2); font-size: .86rem; font-weight: 600; text-decoration: none; }
.filters a.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.searchbar { position: relative; }
.searchbar .ic { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.searchbar .input { padding-left: 42px; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 10px; }

/* ---------- document detail ---------- */
.doc-head .ref { font-size: .82rem; color: var(--muted); font-weight: 600; }
.kv { display: grid; grid-template-columns: 1fr; gap: 2px 16px; margin: 0; }
.kv dt { font-size: .8rem; color: var(--muted); font-weight: 600; margin-top: 10px; }
.kv dt:first-child { margin-top: 0; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
@media (min-width: 560px) {
  .kv { grid-template-columns: 170px 1fr; }
  .kv dt { margin-top: 0; padding: 7px 0; }
  .kv dd { padding: 7px 0; }
}
.next-step { border: 1.5px solid var(--brand-100); background: linear-gradient(180deg, #fff, var(--brand-50)); }
.next-step .num { display: inline-flex; width: 26px; height: 26px; border-radius: 50%; background: var(--brand); color: #fff; font-weight: 800; font-size: .85rem; align-items: center; justify-content: center; }
.linkbox { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 14px; border: 1.5px solid var(--line); border-radius: 12px; background: #fafbfc; }
.linkbox .u { flex: 1; min-width: 0; font-weight: 700; font-size: .95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.qrwrap { display: flex; justify-content: center; padding: 12px; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.qrwrap img { width: 200px; height: 200px; image-rendering: pixelated; }
.signer { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; }
.signer + .signer { border-top: 1px solid var(--line-2); }
.signer .av { width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-weight: 800; }
.signer .av.done { background: var(--green-50); color: var(--green); }
.signer .av.wait { background: var(--gray-50); color: #8a8f99; }
.sigimg { display: block; max-height: 56px; max-width: 180px; margin-top: 6px; background: #fff; border: 1px dashed var(--line); border-radius: 8px; padding: 4px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 14px 22px; }
.timeline li::before { content: ""; position: absolute; left: 5px; top: 8px; width: 8px; height: 8px; border-radius: 50%; background: #c9ccd3; }
.timeline li::after { content: ""; position: absolute; left: 8.5px; top: 20px; bottom: 0; width: 1px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.timeline li.hl::before { background: var(--brand); }
.timeline .w { font-size: .78rem; color: var(--muted); }
details.more > summary { cursor: pointer; list-style: none; font-weight: 700; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; }
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::after { content: "+"; font-size: 1.3rem; color: var(--muted); line-height: 1; }
details.more[open] > summary::after { content: "–"; }
details.more > .card-body { border-top: 1px solid var(--line-2); }

/* ---------- tool pages (editor / signing) ---------- */
body.tool { background: #e9eaee; }
.toolbar {
  position: sticky; top: 0; z-index: 30; background: #fff; border-bottom: 1px solid var(--line);
}
.toolbar-in { max-width: 960px; margin: 0 auto; min-height: 58px; padding: 6px 8px; display: flex; align-items: center; gap: 6px; }
.toolbar .ttl { flex: 1; min-width: 0; }
.toolbar .ttl b { display: block; font-size: .98rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toolbar .ttl span { display: block; font-size: .78rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.steps { display: flex; gap: 6px; padding: 8px 12px 10px; max-width: 960px; margin: 0 auto; }
.steps i { flex: 1; height: 4px; border-radius: 99px; background: var(--line); }
.steps i.on { background: var(--brand); }
.actionbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 35; background: #fff; border-top: 1px solid var(--line);
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); box-shadow: 0 -4px 18px rgba(0, 0, 0, .06);
}
.actionbar-in { max-width: 960px; margin: 0 auto; display: flex; gap: 8px; align-items: center; }
.actionbar .btn { flex: 1; }
body.tool main { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }

/* PDF viewer */
.viewer { max-width: 900px; margin: 0 auto; padding: 12px 8px; }
.pdf-page { position: relative; margin: 0 auto 14px; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .12), 0 6px 18px rgba(0, 0, 0, .06); border-radius: 4px; overflow: hidden; }
.pdf-page canvas { display: block; width: 100%; height: 100%; }
.pdf-page .pg-label { position: absolute; right: 8px; bottom: 8px; z-index: 3; font-size: .72rem; font-weight: 700; color: #fff; background: rgba(22, 23, 27, .65); padding: 2px 8px; border-radius: 99px; pointer-events: none; }
.pdf-page .pg-loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: .85rem; }
.viewer-status { text-align: center; padding: 40px 16px; color: var(--muted); }
.viewer-status .spin { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; margin: 0 auto 12px; }
.zoombar { display: flex; gap: 6px; justify-content: center; align-items: center; padding: 4px 0 0; }

/* Signature areas */
.sig-box {
  position: absolute; z-index: 4; border: 2px solid var(--c); background: color-mix(in srgb, var(--c) 12%, transparent);
  border-radius: 6px; touch-action: none; user-select: none; -webkit-user-select: none;
}
.sig-box.first { --c: var(--first); }
.sig-box.second { --c: var(--second); }
@supports not (background: color-mix(in srgb, red 10%, transparent)) {
  .sig-box.first { background: rgba(217, 20, 27, .12); }
  .sig-box.second { background: rgba(31, 95, 214, .12); }
}
.sig-box .tag {
  position: absolute; left: -2px; top: -22px; height: 22px; padding: 0 8px; border-radius: 6px 6px 0 0; background: var(--c);
  color: #fff; font-size: .7rem; font-weight: 800; line-height: 22px; white-space: nowrap; pointer-events: none;
}
.sig-box.flip .tag { top: auto; bottom: -22px; border-radius: 0 0 6px 6px; }
.sig-box.editable { cursor: move; }
.sig-box .del {
  position: absolute; right: -14px; top: -14px; width: 30px; height: 30px; border-radius: 50%; border: 2px solid #fff;
  background: var(--ink); color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 0;
}
.sig-box .rs {
  position: absolute; right: -12px; bottom: -12px; width: 28px; height: 28px; border-radius: 50%; background: var(--c);
  border: 3px solid #fff; cursor: nwse-resize; box-shadow: 0 1px 4px rgba(0, 0, 0, .3);
}
.sig-box.active { box-shadow: 0 0 0 3px rgba(255, 255, 255, .9), 0 0 0 5px var(--c); }
.sig-box.target { animation: pulse 1.6s ease-in-out infinite; }
.sig-box.target .hint-in { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; color: var(--c); font-weight: 800; font-size: clamp(.6rem, 2.4vw, .85rem); line-height: 1.1; padding: 2px; }
.sig-box.filled { background: transparent; border-style: dashed; animation: none; }
.sig-box.filled .hint-in { display: none; }
.sig-box img.sig-preview { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(31, 95, 214, .35); } 50% { box-shadow: 0 0 0 7px rgba(31, 95, 214, 0); } }

.legend { display: flex; flex-wrap: wrap; gap: 8px 14px; font-size: .84rem; font-weight: 600; color: var(--ink-2); }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legend .l1 { background: var(--first); }
.legend .l2 { background: var(--second); }
.tipcard { max-width: 900px; margin: 12px auto 0; padding: 0 8px; }

/* Signature pad */
.pad-wrap { position: relative; border: 2px dashed #c9ccd3; border-radius: 14px; background: #fff; overflow: hidden; touch-action: none; }
.pad-wrap.signed { border-style: solid; border-color: var(--blue); }
.pad-wrap canvas { display: block; width: 100%; height: 200px; touch-action: none; cursor: crosshair; }
@media (min-width: 720px) { .pad-wrap canvas { height: 240px; } }
.pad-wrap .baseline { position: absolute; left: 18px; right: 18px; bottom: 46px; border-bottom: 1.5px solid #e0e2e6; pointer-events: none; }
.pad-wrap .placeholder { position: absolute; left: 0; right: 0; bottom: 58px; text-align: center; color: #a3a7b0; font-weight: 600; pointer-events: none; }
.pad-wrap.signed .placeholder { display: none; }
.pad-wrap .x { position: absolute; left: 18px; bottom: 50px; color: #b9bcc4; font-weight: 700; pointer-events: none; }
.pad-tools { display: flex; gap: 8px; margin-top: 8px; }
.pad-tools .btn { flex: 1; }

/* Overlay (progress) */
.overlay { position: fixed; inset: 0; z-index: 100; background: rgba(22, 23, 27, .55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.overlay .box { width: 100%; max-width: 380px; background: #fff; border-radius: 18px; padding: 24px; text-align: center; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.overlay .big-spin { width: 46px; height: 46px; border: 4px solid var(--brand-100); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; margin: 0 auto 14px; }
.proc-steps { text-align: left; list-style: none; padding: 0; margin: 14px 0 0; }
.proc-steps li { display: flex; gap: 10px; align-items: center; padding: 6px 0; color: var(--muted); font-weight: 600; font-size: .92rem; }
.proc-steps li .dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.proc-steps li.on { color: var(--ink); }
.proc-steps li.on .dot { border-color: var(--brand); border-right-color: transparent; animation: spin .8s linear infinite; }
.proc-steps li.ok { color: var(--green); }
.proc-steps li.ok .dot { border-color: var(--green); background: var(--green); color: #fff; }

/* Sheet (modal from bottom on mobile) */
.sheet { position: fixed; inset: 0; z-index: 90; display: flex; align-items: flex-end; justify-content: center; background: rgba(22, 23, 27, .5); }
.sheet .panel { width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; background: #fff; border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }
@media (min-width: 620px) { .sheet { align-items: center; } .sheet .panel { border-radius: 20px; } }
.sheet .grab { width: 40px; height: 4px; border-radius: 99px; background: var(--line); margin: -6px auto 12px; }

/* Toast */
.toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 120; background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 999px; font-weight: 600; font-size: .92rem; box-shadow: 0 8px 24px rgba(0, 0, 0, .25); max-width: calc(100vw - 32px); text-align: center; }

/* ---------- public (EO) pages ---------- */
body.public { background: #f4f4f6; }
.pub-head { background: #fff; border-bottom: 1px solid var(--line); }
.pub-head .in { max-width: 900px; margin: 0 auto; height: 58px; padding: 0 16px; display: flex; align-items: center; justify-content: space-between; }
.pub-head img { height: 32px; width: auto; }
.secure { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 700; color: var(--green); }
.pub-foot { text-align: center; color: var(--muted); font-size: .8rem; padding: 24px 16px 32px; }
.hero-doc { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.hero-doc .from { font-size: .82rem; color: var(--muted); font-weight: 600; }
.hero-doc h1 { font-size: 1.25rem; margin: 4px 0 10px; }
.parties { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.parties div { background: var(--bg); border-radius: 10px; padding: 8px 10px; min-width: 0; }
.parties small { display: block; font-size: .72rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.parties b { display: block; font-size: .92rem; overflow-wrap: anywhere; }
.state-page { max-width: 480px; margin: 0 auto; padding: 32px 16px; text-align: center; }
.state-icon { width: 76px; height: 76px; border-radius: 50%; margin: 0 auto 16px; display: flex; align-items: center; justify-content: center; }
.state-icon.ok { background: var(--green-50); color: var(--green); }
.state-icon.warn { background: var(--amber-50); color: var(--amber); }
.state-icon.err { background: var(--red-50); color: var(--red); }
.state-icon.info { background: var(--blue-50); color: var(--blue); }
.consent { background: #fafbfc; border: 1.5px solid var(--line); border-radius: 12px; padding: 14px; }
.consent.ok { border-color: #bfe5d4; background: var(--green-50); }

/* Login */
.auth-wrap { min-height: calc(100vh - 140px); display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card .logo-big { display: block; margin: 0 auto 18px; height: 56px; width: auto; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Back button stays compact so the primary action keeps one line on phones. */
.actionbar #btnBack { flex: 0 0 auto; padding: 0 14px; }
.actionbar .btn { white-space: nowrap; }

/* ======================= Mobile comfort additions ======================= */
a, button, label, summary { -webkit-tap-highlight-color: transparent; }
.btn-sm { min-height: 42px; }
.pdf-page canvas.pg-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.pdf-page { cursor: zoom-in; }
.pg-zoom {
  position: absolute; top: 8px; right: 8px; z-index: 3; display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 9px; border-radius: 99px; background: rgba(22, 23, 27, .68); color: #fff; font-size: .72rem; font-weight: 700;
  pointer-events: none;
}
#zoomBar { max-width: 900px; margin: 10px auto 0; padding: 0 8px; display: flex; gap: 8px; }
#zoomBar .btn { flex: 1; }
.viewer-tools.hidden { display: none; }

/* Keyboard open on phones: keep the input visible, hide the sticky bar. */
body.typing .actionbar { display: none; }
body.typing main { padding-bottom: 24px; }

/* Scroll lock while a full-screen layer is open */
html.fsv-lock, html.fsv-lock body { overflow: hidden; overscroll-behavior: none; }

/* Full-screen reader */
.fsv { position: fixed; inset: 0; z-index: 200; display: none; flex-direction: column; background: #2a2c31; height: 100vh; height: 100dvh; }
.fsv.on { display: flex; }
.fsv-bar {
  display: flex; align-items: center; gap: 4px; padding: 6px 6px calc(6px) calc(6px + env(safe-area-inset-left));
  padding-top: calc(6px + env(safe-area-inset-top)); background: #17181c; color: #fff; flex-shrink: 0;
}
.fsv-btn { width: 48px; height: 48px; border: 0; border-radius: 12px; background: transparent; color: #fff; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.fsv-btn:active { background: rgba(255, 255, 255, .14); }
.fsv-title { flex: 1; min-width: 0; text-align: center; }
.fsv-title b { display: block; font-size: .95rem; }
.fsv-title span { display: block; font-size: .74rem; opacity: .7; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fsv-scroll { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; touch-action: pan-x pan-y; overscroll-behavior: contain; }
.fsv-pages { padding: 10px 6px 40px; max-width: none; transform-origin: 0 0; will-change: transform; }
.fsv-pages .pdf-page { cursor: default; box-shadow: 0 2px 10px rgba(0, 0, 0, .35); margin-bottom: 10px; }
.fsv-hint, .fsv-zoom {
  position: absolute; left: 50%; transform: translateX(-50%); background: rgba(0, 0, 0, .78); color: #fff;
  border-radius: 99px; font-weight: 600; pointer-events: none; transition: opacity .3s;
}
.fsv-hint { bottom: calc(18px + env(safe-area-inset-bottom)); padding: 9px 16px; font-size: .85rem; width: max-content; max-width: calc(100vw - 32px); text-align: center; }
.fsv-hint.gone { opacity: 0; }
.fsv-zoom { top: 45%; padding: 8px 16px; font-size: 1.1rem; opacity: 0; }
.fsv-zoom.on { opacity: 1; }

/* Full-screen signature pad */
.padfs { position: fixed; inset: 0; z-index: 210; background: #f1f2f4; display: flex; flex-direction: column; height: 100vh; height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
.padfs.hidden { display: none; }
.padfs-bar { padding: 10px 14px 6px; display: flex; flex-direction: column; gap: 2px; }
.padfs-bar span { color: var(--muted); }
.padfs-slot { flex: 1; min-height: 0; padding: 4px 12px; display: flex; }
.padfs-slot .pad-wrap { flex: 1; display: flex; }
.padfs-slot .pad-wrap canvas { height: 100% !important; min-height: 160px; }
.padfs-actions { display: flex; gap: 8px; padding: 8px 12px 12px; }
.padfs-actions .btn { flex: 1; }
@media (orientation: landscape) and (max-height: 500px) {
  .padfs-bar { padding: 6px 12px 2px; flex-direction: row; align-items: baseline; gap: 10px; }
  .padfs-actions { padding: 6px 12px 8px; }
  .padfs-actions .btn { min-height: 42px; }
}
.editor-zoom { max-width: 900px; margin: 10px auto 0; padding: 0 8px; display: flex; gap: 8px; align-items: center; justify-content: center; }
.editor-zoom span { min-width: 54px; text-align: center; font-weight: 700; }
.editor-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.editor-scroll .pdf-page { cursor: default; }
/* Portrait phones: keep the full-screen pad wide (signatures are wide), centred. */
@media (orientation: portrait) {
  .padfs-slot { align-items: center; }
  .padfs-slot .pad-wrap { flex: 1; height: min(100%, 78vw); }
}
.padfs-actions .btn { min-width: 0; padding: 0 10px; white-space: nowrap; }
.padfs-actions #padFsDone { flex: 1.4; }
.sig-box .tag { max-width: calc(100% + 4px); overflow: hidden; text-overflow: ellipsis; }
body.typing .bottomnav { display: none; }
body.typing.has-bottomnav main { padding-bottom: 24px; }
