@font-face { font-family: Inter; font-weight: 400; font-display: swap; src: url(fonts/inter-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: Inter; font-weight: 500; font-display: swap; src: url(fonts/inter-latin-500-normal.woff2) format("woff2"); }
@font-face { font-family: Inter; font-weight: 600; font-display: swap; src: url(fonts/inter-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: Poppins; font-weight: 500; font-display: swap; src: url(fonts/poppins-latin-500-normal.woff2) format("woff2"); }
@font-face { font-family: Poppins; font-weight: 600; font-display: swap; src: url(fonts/poppins-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: InkSignature; font-weight: 400; font-display: block; src: url(fonts/signature.woff2) format("woff2"); }

:root {
  --ink: #1A1A1A; --muted: #555555; --line: #E2E2E2; --soft: #EDEDED; --bg: #F2F2F2;
  --accent: #C8102E; --accent-dark: #9E0C24; --pink: #FBE3E8; --blue: #1F5FBF; --bluebg: #E8EFFB;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 400 15px/1.5 Inter, "Segoe UI", system-ui, sans-serif; color: var(--ink); background: var(--bg); font-variant-numeric: tabular-nums; }
a { color: var(--accent); }
a:hover { color: var(--accent-dark); }
h1, h2, h3 { font-family: Poppins, Inter, sans-serif; font-weight: 600; letter-spacing: -0.01em; margin: 0; }
h1 { font-size: 30px; line-height: 1.2; }
h2 { font-size: 19px; }
:focus-visible { outline: 3px solid #1F5FBF; outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }

/* shell */
.shell { display: flex; flex-wrap: wrap; min-height: 100vh; }
.side { flex: 1 1 232px; max-width: 100%; background: #fff; border-right: 1px solid var(--line); padding: 28px 20px; display: flex; flex-direction: column; gap: 32px; }
.brand { display: flex; flex-direction: column; gap: 8px; text-decoration: none; color: var(--ink); }
.brand img { width: 148px; height: auto; }
.brand span { font: 600 22px Poppins, Inter, sans-serif; padding-left: 2px; }
.navlinks { display: flex; flex-direction: column; gap: 4px; }
.navlinks a { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 14px; border-radius: 8px; color: var(--ink); text-decoration: none; font-weight: 500; }
.navlinks a:hover { background: var(--bg); color: var(--ink); }
.navlinks a[aria-current] { background: var(--ink); color: #fff; }
.badge { margin-left: auto; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--accent); color: #fff; font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; }
.who { margin-top: auto; font-size: 13px; color: var(--muted); }
@media (min-width: 721px) { .side { position: sticky; top: 0; height: 100vh; overflow-y: auto; align-self: flex-start; } }
.main { flex: 999 1 560px; min-width: 0; padding: 36px 48px 56px; display: flex; flex-direction: column; gap: 24px; }
@media (max-width: 720px) {
  .side { padding: 16px; gap: 14px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { flex-direction: row; align-items: center; }
  .brand img { width: 110px; }
  .navlinks { flex-direction: row; flex-wrap: wrap; }
  .who { display: none; }
  .main { padding: 20px 16px 40px; }
}

/* pieces */
.head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.head .sub { font-size: 14px; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.cols { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.cols > .wide { flex: 3 1 520px; min-width: 0; display: flex; flex-direction: column; gap: 24px; }
.cols > .narrow { flex: 2 1 320px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.btn { min-height: 44px; padding: 0 18px; border-radius: 8px; font: 600 15px Inter, sans-serif; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; border: 1px solid #D6D6D6; background: #fff; color: var(--ink); white-space: nowrap; }
.btn:hover { background: #F7F7F7; color: var(--ink); }
.btn.primary { border-color: var(--accent); background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }
.btn.dark { border-color: var(--ink); background: var(--ink); color: #fff; }
.btn.dark:hover { background: #333; color: #fff; }
.btn.small { min-height: 38px; padding: 0 12px; font-size: 14px; }
.btn[disabled] { background: var(--line); border-color: var(--line); color: var(--muted); cursor: not-allowed; }
.linkbtn { border: 0; background: none; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-decoration: underline; }
.iconbtn { width: 44px; height: 44px; border-radius: 8px; border: 1px solid #D6D6D6; background: #fff; color: var(--ink); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; flex: none; }
label.f { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 500; }
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  min-height: 44px; padding: 0 12px; border: 1px solid #D6D6D6; border-radius: 8px; background: #fff; font: 400 15px Inter, sans-serif; color: var(--ink); width: 100%; }
textarea { padding: 10px 12px; line-height: 1.5; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--ink); outline: none; box-shadow: 0 0 0 2px rgba(31,95,191,.25); }
.check { display: flex; align-items: center; gap: 10px; min-height: 40px; }
.check input { width: 20px; height: 20px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.flash { padding: 14px 16px; border-radius: 10px; background: var(--ink); color: #fff; font-size: 14px; }
.flash a { color: #fff; font-weight: 600; }
.flash.err { background: var(--pink); color: var(--accent-dark); }
.alert { padding: 12px 14px; border-radius: 8px; background: var(--pink); color: var(--accent-dark); font-size: 14px; }
.note { padding: 12px 14px; border-radius: 8px; background: var(--bg); font-size: 14px; }
.chip { font-size: 13px; font-weight: 600; padding: 3px 12px; border-radius: 999px; white-space: nowrap; border: 1.5px solid; display: inline-block; }
.chip.wait { background: #fff; color: var(--ink); border: 1.5px dashed var(--ink); }
.chip.done { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip.draft { background: var(--soft); color: var(--ink); border-color: var(--soft); }
.chip.bad { background: var(--pink); color: var(--accent-dark); border-color: var(--pink); }

/* documents list */
.drop { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 14px; min-height: 110px; padding: 20px; border: 2px dashed #BDBDBD; border-radius: 12px; background: #fff; cursor: pointer; text-align: left; }
.drop.over { border-color: var(--accent); background: #FFF7F8; }
.drop .circle { width: 44px; height: 44px; border-radius: 22px; background: var(--bg); display: inline-flex; align-items: center; justify-content: center; }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.tabs a { min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid #D6D6D6; background: #fff; color: var(--ink); text-decoration: none; display: inline-flex; align-items: center; font-size: 14px; font-weight: 500; }
.tabs a[aria-current] { background: var(--ink); border-color: var(--ink); color: #fff; }
.scrollx { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; min-width: 720px; }
table.list th { text-align: left; font-size: 13px; font-weight: 400; color: var(--muted); padding: 0 8px 10px; border-bottom: 1px solid var(--soft); }
table.list td { padding: 14px 8px; border-bottom: 1px solid var(--soft); vertical-align: middle; }
.docname { display: flex; align-items: center; gap: 12px; }
.pdfic { flex: none; width: 36px; height: 44px; border-radius: 4px; border: 1px solid #D6D6D6; background: #fff; display: inline-flex; align-items: flex-end; justify-content: center; padding-bottom: 4px; font-size: 10px; font-weight: 600; color: var(--accent-dark); }

/* login */
.split { display: flex; flex-wrap: wrap; min-height: 100vh; }
.split .dark { flex: 1 1 420px; background: var(--ink); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; gap: 40px; }
.split .big { font: 600 88px/1 Poppins, Inter, sans-serif; letter-spacing: -0.03em; }
.split .lead { font-size: 20px; line-height: 1.5; color: #E6E6E6; max-width: 480px; }
.split .fine { font-size: 14px; color: #CFCFCF; max-width: 440px; }
.split .right { flex: 1 1 480px; padding: 56px 24px; display: flex; align-items: center; justify-content: center; }
.authcard { width: 100%; max-width: 420px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 36px; display: flex; flex-direction: column; gap: 18px; }
.authcard img { width: 140px; }
@media (max-width: 720px) { .split .dark { padding: 28px 24px; } .split .big { font-size: 56px; } }

/* signature pad modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.modal .box { width: 100%; max-width: 440px; background: #fff; border-radius: 12px; padding: 24px; display: flex; flex-direction: column; gap: 14px; max-height: 100%; overflow: auto; }
.modal .top { display: flex; justify-content: space-between; align-items: center; }
.seg { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--ink); border-radius: 8px; overflow: hidden; }
.seg button { min-height: 44px; border: 0; background: #fff; color: var(--ink); font: 600 15px Inter, sans-serif; cursor: pointer; }
.seg button[aria-pressed=true] { background: var(--ink); color: #fff; }
.padwrap { position: relative; border: 1px solid #D6D6D6; border-radius: 8px; background: #FAFAFA; }
.padwrap canvas { display: block; width: 100%; height: 150px; touch-action: none; cursor: crosshair; }
.padwrap .baseline { position: absolute; left: 16px; right: 16px; bottom: 30px; border-bottom: 1px solid #BDBDBD; pointer-events: none; }
.padwrap .hint { position: absolute; right: 10px; bottom: 6px; font-size: 12px; color: var(--muted); pointer-events: none; }
.sigprev { height: 96px; border: 1px solid var(--line); border-radius: 8px; background: #FAFAFA; display: flex; align-items: center; justify-content: center; }
.sigprev img { max-height: 80px; max-width: 90%; }

/* PDF pages (editor, signing, status) */
.pagesbox { background: #E4E4E4; border-radius: 12px; padding: 24px; display: flex; flex-direction: column; align-items: center; gap: 24px; overflow-x: auto; }
.pdfpage { position: relative; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.18); flex: none; }
.pdfpage canvas { display: block; }
.pdfpage .layer { position: absolute; inset: 0; }
.pagelabel { font-size: 12px; color: var(--muted); margin-bottom: -16px; align-self: center; }
.it { position: absolute; box-sizing: border-box; }
.it.text { white-space: pre; line-height: 1.2; font-family: Helvetica, Arial, sans-serif; padding: 0; outline: none; min-width: 8px; }
.it.hl { background: rgba(255, 228, 92, .5); mix-blend-mode: multiply; }
.it.white { background: #fff; }
.it.img img { width: 100%; height: 100%; display: block; object-fit: contain; }
.it.check svg { width: 100%; height: 100%; display: block; }
.it.field { border: 1.5px dashed; border-radius: 3px; display: flex; align-items: center; justify-content: center; gap: 5px; font: 600 12px Inter, sans-serif; overflow: hidden; white-space: nowrap; padding: 0 4px; }
.it.field.mine { border-style: solid; border-width: 2px; cursor: pointer; }
.it.field.mine:hover { filter: brightness(.96); }
.it.field.done { border-color: transparent !important; background: transparent !important; }
.it.field.done img { max-width: 100%; max-height: 100%; }
.editing .it { cursor: move; }
.editing .it.sel { outline: 2px solid var(--ink); outline-offset: 1px; }
.editing .it.text.sel { cursor: text; }
.grip { position: absolute; right: -6px; bottom: -6px; width: 11px; height: 11px; background: var(--ink); border: 1px solid #fff; cursor: nwse-resize; }

/* editor */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px; background: #fff; border: 1px solid var(--line); border-radius: 12px; position: sticky; top: 0; z-index: 5; }
.toolbar button { min-height: 44px; padding: 0 14px; border-radius: 8px; border: 0; background: transparent; color: var(--ink); font: 500 14px Inter, sans-serif; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; }
.toolbar button:hover { background: var(--bg); }
.toolbar button[aria-pressed=true] { background: var(--ink); color: #fff; }
.toolbar .hint { margin-left: auto; padding: 0 10px; font-size: 14px; color: var(--muted); }
.edgrid { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.edgrid .pagesbox { flex: 1 1 520px; min-width: 0; }
.edgrid aside { flex: 1 1 260px; max-width: 340px; min-width: 240px; display: flex; flex-direction: column; gap: 16px; position: sticky; top: 76px; }
.who-btn { min-height: 48px; padding: 0 12px; border-radius: 8px; border: 2px solid var(--line); background: #fff; cursor: pointer; display: flex; align-items: center; gap: 10px; font: 500 14px Inter, sans-serif; color: var(--ink); text-align: left; width: 100%; }
.who-btn .sw { width: 14px; height: 14px; border-radius: 3px; flex: none; }
.who-btn .n { margin-left: auto; font-size: 12px; color: var(--muted); }
@media (max-width: 900px) { .edgrid aside { position: static; max-width: none; } }

/* signer page */
.signbar { position: sticky; top: 0; z-index: 5; background: #fff; border-bottom: 1px solid var(--line); padding: 12px 24px; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; }
.signbar img { width: 110px; }
.signbar .t { flex: 1 1 260px; display: flex; flex-direction: column; min-width: 0; }
.signbody { padding: 24px 12px 48px; display: flex; flex-direction: column; align-items: center; gap: 20px; }
.signbody .pagesbox { background: transparent; padding: 0; width: 100%; }
.banner { width: 100%; max-width: 760px; padding: 18px 22px; border-radius: 12px; background: var(--ink); color: #fff; display: flex; flex-direction: column; gap: 6px; }
.banner.light { background: #fff; color: var(--ink); border: 1px solid var(--line); }

/* activity */
.evt { display: grid; grid-template-columns: 170px minmax(0, 1.6fr) minmax(0, 1.4fr) 130px; gap: 16px; padding: 12px 4px; border-top: 1px solid var(--soft); font-size: 14px; }
.person { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-top: 1px solid var(--soft); flex-wrap: wrap; }
.dot { flex: none; width: 36px; height: 36px; border-radius: 18px; display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: 14px; border: 2px solid #D6D6D6; color: var(--muted); }
.dot.done { background: var(--ink); color: #fff; border-color: var(--ink); }
.dot.wait { border: 2px dashed var(--ink); color: var(--ink); }
.dot.bad { background: var(--pink); color: var(--accent-dark); border-color: var(--pink); }

.tplgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 20px; }
.thumbbox { height: 120px; border-radius: 6px; background: var(--bg); display: flex; align-items: center; justify-content: center; }
