/* Fonts: Frank Ruhl Libre for the protocol text, Heebo for the interface */
@font-face { font-family: "Heebo"; font-weight: 400; font-display: swap; src: url(fonts/heebo-hebrew-400-normal.woff2) format("woff2"); unicode-range: U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F; }
@font-face { font-family: "Heebo"; font-weight: 500; font-display: swap; src: url(fonts/heebo-hebrew-500-normal.woff2) format("woff2"); unicode-range: U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F; }
@font-face { font-family: "Heebo"; font-weight: 700; font-display: swap; src: url(fonts/heebo-hebrew-700-normal.woff2) format("woff2"); unicode-range: U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F; }
@font-face { font-family: "Heebo"; font-weight: 400; font-display: swap; src: url(fonts/heebo-latin-400-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Heebo"; font-weight: 500; font-display: swap; src: url(fonts/heebo-latin-500-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Heebo"; font-weight: 700; font-display: swap; src: url(fonts/heebo-latin-700-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Frank Ruhl Libre"; font-weight: 400; font-display: swap; src: url(fonts/frank-ruhl-libre-hebrew-400-normal.woff2) format("woff2"); unicode-range: U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F; }
@font-face { font-family: "Frank Ruhl Libre"; font-weight: 500; font-display: swap; src: url(fonts/frank-ruhl-libre-hebrew-500-normal.woff2) format("woff2"); unicode-range: U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F; }
@font-face { font-family: "Frank Ruhl Libre"; font-weight: 700; font-display: swap; src: url(fonts/frank-ruhl-libre-hebrew-700-normal.woff2) format("woff2"); unicode-range: U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F; }
@font-face { font-family: "Frank Ruhl Libre"; font-weight: 400; font-display: swap; src: url(fonts/frank-ruhl-libre-latin-400-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Frank Ruhl Libre"; font-weight: 500; font-display: swap; src: url(fonts/frank-ruhl-libre-latin-500-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Frank Ruhl Libre"; font-weight: 700; font-display: swap; src: url(fonts/frank-ruhl-libre-latin-700-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --ink: #17233b;          /* printed text, deep navy */
  --pen: #1c3fa8;          /* signature ink, ballpoint blue */
  --paper: #ffffff;
  --desk: #e9ecf1;         /* page background behind the sheet */
  --rule: #c5ccd8;
  --muted: #566176;
  --ok: #1d7a4b;
  --danger: #b3261e;
  --focus: #1c3fa8;
  --serif: "Frank Ruhl Libre", "Times New Roman", serif;
  --sans: "Heebo", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--desk);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.6;
}
[hidden] { display: none !important; }

.wrap { max-width: 720px; margin: 0 auto; padding: 16px 14px 48px; }

/* Letterhead: the building name, on every screen and on the PDF */
.brand {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.25rem;
  text-align: center;
  padding: 6px 0 12px;
  margin-bottom: 14px;
  border-bottom: 3px double var(--ink);
}

/* The sheet: the protocol as a page of paper */
.sheet {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 3px;
  box-shadow: 0 1px 0 var(--rule), 0 10px 24px -14px rgba(23, 35, 59, .35);
  padding: 28px 22px 32px;
}
.sheet h1 {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.7rem;
  line-height: 1.25;
  margin: 0 0 6px;
}
.meta { color: var(--muted); font-size: .95rem; margin: 0 0 20px; padding-bottom: 14px; border-bottom: 2px solid var(--ink); }
.doc { font-family: var(--serif); font-size: 1.12rem; line-height: 1.85; max-width: 62ch; }
.doc p { margin: 0 0 .9em; white-space: pre-wrap; }
.doc h2 { font-size: 1.25rem; font-weight: 700; margin: 1.4em 0 .4em; }
.doc ul { margin: 0 0 .9em; padding: 0; list-style: none; }
.doc li { margin-bottom: .25em; position: relative; padding-inline-start: 1.2em; }
.doc li::before { content: "•"; position: absolute; inset-inline-start: .1em; }

/* Forms */
.panel {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 22px;
  margin-top: 16px;
}
.panel h2 { font-size: 1.15rem; margin: 0 0 14px; }
label { display: block; font-weight: 500; margin-bottom: 4px; }
.field { margin-bottom: 14px; }
input[type=text], input[type=password], input[type=date], textarea {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: #fff;
  border: 1.5px solid var(--rule);
  border-radius: 3px;
  padding: 11px 12px;
  min-height: 48px;
}
textarea { min-height: 280px; font-family: var(--serif); font-size: 1.1rem; line-height: 1.7; resize: vertical; }
input:focus, textarea:focus, button:focus-visible, a:focus-visible, canvas:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-color: var(--focus);
}
.row { display: grid; grid-template-columns: 1fr 120px; gap: 12px; }
.meta-row { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.when { color: var(--muted); font-size: .82rem; }
.btn.x { min-height: 38px; min-width: 38px; padding: 0; }
.hint { color: var(--muted); font-size: .9rem; margin: 4px 0 0; }

/* Buttons */
.btn {
  font: inherit; font-weight: 500;
  min-height: 48px; padding: 0 20px;
  border-radius: 3px; border: 1.5px solid var(--ink);
  background: var(--ink); color: #fff; cursor: pointer;
}
.btn:hover { background: #0e1830; }
.btn.secondary { background: #fff; color: var(--ink); }
.btn.secondary:hover { background: #f2f4f8; }
.btn.danger { background: #fff; color: var(--danger); border-color: var(--danger); }
.btn.small { min-height: 38px; padding: 0 12px; font-size: .92rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.block { width: 100%; }

/* Signature pad: a ruled line, like signing on paper */
.pad-label { display: flex; justify-content: space-between; align-items: baseline; }
.pad {
  position: relative;
  height: 190px;
  border: 1.5px solid var(--rule);
  border-radius: 3px;
  background: #fff;
  touch-action: none;
}
.pad canvas { width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; }
.pad::after {
  content: "";
  position: absolute; inset-inline: 16px; bottom: 44px;
  border-bottom: 1.5px solid var(--ink);
  pointer-events: none;
}
.pad .x {
  position: absolute; inset-inline-start: 16px; bottom: 50px;
  font-family: var(--serif); font-size: 1.4rem; color: var(--ink);
  pointer-events: none;
}
.pad .placeholder {
  position: absolute; inset-inline: 0; bottom: 14px; text-align: center;
  color: var(--muted); font-size: .9rem; pointer-events: none;
}
.pad.has-ink .placeholder, .pad.has-ink .x { display: none; }

/* Messages */
.msg { padding: 12px 14px; border-radius: 3px; margin: 12px 0; border: 1.5px solid; }
.msg.error { color: var(--danger); border-color: var(--danger); background: #fdf1f0; }
.msg.warn { color: #7a4a00; border-color: #c98a1a; background: #fff7e6; }
.msg.ok { color: var(--ok); border-color: var(--ok); background: #eef8f2; }

.done { text-align: center; padding: 30px 10px; }
.done .tick {
  width: 64px; height: 64px; margin: 0 auto 12px; border-radius: 50%;
  border: 3px solid var(--ok); color: var(--ok); font-size: 2rem; line-height: 58px;
  animation: stamp .35s ease-out;
}
@keyframes stamp { from { transform: scale(1.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .done .tick { animation: none; } }

/* Admin */
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 4px; }
.topbar h1 { font-size: 1.3rem; margin: 0; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: .85rem; font-weight: 500; border: 1.5px solid; }
.badge.draft { color: var(--muted); border-color: var(--muted); }
.badge.open { color: var(--ok); border-color: var(--ok); }
.badge.closed { color: var(--danger); border-color: var(--danger); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.linkbox { display: flex; gap: 8px; align-items: stretch; }
.linkbox input { direction: ltr; text-align: left; }

table.sigs { width: 100%; border-collapse: collapse; margin-top: 8px; }
.sigs th, .sigs td { border-bottom: 1px solid var(--rule); padding: 8px 6px; text-align: start; vertical-align: middle; }
.sigs th { font-weight: 500; color: var(--muted); font-size: .9rem; }
.sigs img { height: 44px; width: auto; max-width: 110px; display: block; }

/* Print/PDF layout: a clean A4 document built off-screen */
#pdfRoot { position: fixed; inset-inline-start: -10000px; top: 0; width: 794px; background: #fff; color: #000; direction: rtl; }
.pdf-page { padding: 56px 64px; font-family: var(--serif); }
.pdf-page .brand { font-size: 22px; padding: 0 0 10px; margin-bottom: 24px; }
.pdf-page h1 { font-size: 26px; margin: 0 0 6px; }
.pdf-page .meta { font-family: var(--sans); font-size: 14px; color: #333; border-bottom: 2px solid #000; padding-bottom: 10px; margin-bottom: 22px; }
.pdf-page .doc { font-size: 17px; line-height: 1.8; max-width: none; }
.pdf-page h2.sig-title { font-size: 20px; margin: 34px 0 10px; }
.pdf-page table { width: 100%; border-collapse: collapse; font-family: var(--sans); font-size: 14px; }
.pdf-page th, .pdf-page td { border: 1px solid #555; padding: 6px 8px; text-align: right; vertical-align: middle; }
.pdf-page th { background: #eceff4; }
.pdf-page td.sigcell { width: 190px; height: 64px; padding: 2px 8px; }
.pdf-page td.sigcell img { height: 56px; width: auto; max-width: 170px; display: block; }
.pdf-page tr { page-break-inside: avoid; }
.pdf-page .foot { font-family: var(--sans); font-size: 12px; color: #444; margin-top: 18px; }

@media (min-width: 640px) {
  .sheet { padding: 40px 44px 44px; }
  .sheet h1 { font-size: 2rem; }
}

/* Confirmation dialog */
dialog { border: 1.5px solid var(--ink); border-radius: 3px; padding: 22px; max-width: 420px; width: calc(100% - 32px); color: var(--ink); background: #fff; font-family: var(--sans); }
dialog::backdrop { background: rgba(23, 35, 59, .55); }
dialog p { margin: 0 0 6px; font-size: 1.1rem; }
