:root {
  --bg: #f3f4f7;
  --card: #ffffff;
  --ink: #1b2233;
  --muted: #5d667a;
  --line: #dde1ea;
  --brand: #1f3a8a;
  --brand-ink: #ffffff;
  --brand-soft: #e8edfb;
  --ok: #17734a;
  --ok-soft: #e3f4ec;
  --warn: #9a5b00;
  --warn-soft: #fdf1dc;
  --bad: #b42318;
  --bad-soft: #fde8e6;
  --pen: #0f1752;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 28, 50, 0.06), 0 4px 16px rgba(20, 28, 50, 0.05);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 "Segoe UI", "Noto Sans Hebrew", Arial, system-ui, sans-serif;
}
[hidden] { display: none !important; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--brand); }

.wrap { max-width: 720px; margin: 0 auto; padding: 20px 16px 48px; }
.wrap.wide { max-width: 1180px; }
/* הטופס מותאם בעיקר למחשב (דודי, 20/10): רחב, שדות בשני טורים, חתימה בעכבר; בטלפון הכל נערם */
.wrap.form { max-width: 940px; padding-top: 28px; }
.wrap.form .card { padding: 24px 28px 22px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 20px 18px;
  margin: 0 0 14px;
}
.card h2 { margin: 0 0 12px; font-size: 1.08rem; }
.card h2 .sub { font-weight: 400; color: var(--muted); font-size: .9rem; margin-inline-start: 6px; }

/* ---------- כותרת הטופס ---------- */
.doc-head { text-align: center; margin: 8px 0 18px; }
.doc-head .eyebrow { color: var(--muted); font-size: .92rem; min-height: 1.4em; }
.doc-head h1 { font-size: 1.35rem; line-height: 1.35; margin: 4px 0 0; text-wrap: balance; }

/* ---------- שדות ---------- */
.fld { display: block; margin: 0 0 12px; }
.fld > span { display: block; font-weight: 600; font-size: .92rem; margin: 0 0 4px; }
.fld input, .fld textarea, .fld select {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  background: #fff;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.fld textarea { resize: vertical; min-height: 96px; }
.fld input:focus, .fld textarea:focus, .fld select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.fld input[dir="ltr"] { text-align: left; }
.fld .hint { display: block; color: var(--muted); font-size: .85rem; margin-top: 4px; }
.fld.ro output { display: block; padding: 10px 12px; border-radius: 10px; background: #f6f7fa; border: 1px dashed var(--line); }
.bad input, .bad textarea, input.bad { border-color: var(--bad) !important; box-shadow: 0 0 0 3px var(--bad-soft) !important; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } }

.legal { color: #3a4256; font-size: .95rem; margin: 0 0 12px; }
.lead { font-weight: 600; margin: 0 0 6px; }
.note { color: var(--muted); font-size: .88rem; margin: 10px 0 0; }

/* ---------- חלופות ---------- */
.opts { display: grid; gap: 10px; margin: 12px 0 4px; }
.opt {
  position: relative;
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 2px 10px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 12px 12px 12px 14px;
  cursor: pointer;
  background: #fff;
  transition: border-color .15s, background-color .15s, box-shadow .15s;
}
.opt input { position: absolute; opacity: 0; pointer-events: none; }
.opt .box {
  grid-row: span 2;
  width: 26px; height: 26px;
  border: 2px solid #8a93a8;
  border-radius: 6px;
  display: grid; place-items: center;
  font-weight: 700;
  color: transparent;
  margin-top: 1px;
  transition: border-color .15s, background-color .15s;
}
.opt .box::after { content: "✕"; font-size: 17px; line-height: 1; }
.opt b { font-size: .98rem; }
.opt small { color: var(--muted); font-size: .86rem; line-height: 1.5; }
.opt:hover { border-color: #aab3c8; }
.opt:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); box-shadow: 0 0 0 2px var(--brand) inset; }
.opt:has(input:checked) .box { border-color: var(--brand); color: var(--pen); background: #fff; }
.opt:has(input:focus-visible) { outline: 3px solid var(--brand-soft); outline-offset: 2px; }
.opt.struck { cursor: not-allowed; background: #f6f7fa; }
.opt.struck b, .opt.struck small { text-decoration: line-through; color: #8d94a5; }
.opt.struck .box { opacity: .4; }
.opt .tag {
  position: absolute; top: 10px; inset-inline-end: 12px;
  font-size: .75rem; color: var(--muted); background: #eceef3; border-radius: 99px; padding: 1px 8px;
}
.opt-sep { color: var(--muted); font-size: .86rem; margin: 6px 2px 0; }
.bad .opt { border-color: #e9a29b; }

.reveal .fld { margin: 0; }
.reveal { margin-top: 12px; padding: 12px 14px; border-radius: 12px; background: #f8f9fc; border: 1px solid var(--line); }

/* ---------- חלק ב' ---------- */
.partb ul { margin: 6px 0 12px; padding-inline-start: 20px; }
.partb li { margin: 0 0 6px; font-size: .95rem; color: #3a4256; }

.check { display: flex; gap: 10px; align-items: flex-start; margin: 12px 0 0; cursor: pointer; font-size: .95rem; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; flex: none; accent-color: var(--brand); }
.check.bad { color: var(--bad); }

/* ---------- חתימה ---------- */
.sig-box {
  position: relative;
  border: 1.5px dashed #9aa3b8;
  border-radius: 12px;
  background: #fff;
  height: 190px;
  touch-action: none;
}
.sig-box.bad { border-color: var(--bad); border-style: solid; box-shadow: 0 0 0 3px var(--bad-soft); }
.sig-box canvas { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 12px; cursor: crosshair; }
.sig-box .base { position: absolute; left: 22px; right: 22px; bottom: 46px; border-bottom: 1.5px solid #c7ccd8; pointer-events: none; }
.sig-box .sig-hint { position: absolute; inset: 0; display: grid; place-items: center; color: #9aa3b8; pointer-events: none; font-size: .95rem; }
.sig-box.has .sig-hint { display: none; }
.sig-box .clear { position: absolute; top: 8px; inset-inline-end: 8px; }
.sig-row { display: grid; grid-template-columns: minmax(0, 520px) 1fr; gap: 20px; align-items: end; }
.sig-side .note { margin: 6px 0 0; }
.sig-meta { display: flex; gap: 8px; align-items: baseline; color: var(--muted); font-size: .92rem; }
.sig-meta b { color: var(--pen); font-size: 1.05rem; font-variant-numeric: tabular-nums; }
@media (max-width: 760px) { .sig-row { grid-template-columns: 1fr; gap: 10px; } }

/* ---------- כפתורים ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1.5px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 8px 14px;
  cursor: pointer;
  text-decoration: none;
  color: var(--ink);
  white-space: nowrap;
  transition: background-color .15s, border-color .15s, transform .1s;
}
.btn:hover { background: #f4f6fa; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; transform: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 600; }
.btn.primary:hover { background: #18307a; }
.btn.big { width: 100%; padding: 14px; font-size: 1.05rem; border-radius: 12px; }
.btn.sm { padding: 4px 10px; font-size: .86rem; border-radius: 8px; }
.btn.wa { border-color: #1fa855; color: #12763a; }
.btn.wa:hover { background: #e9f8ef; }
.btn.danger { color: var(--bad); }

.err { background: var(--bad-soft); color: var(--bad); border-radius: 10px; padding: 10px 14px; margin: 0 0 12px; font-weight: 600; }
.okmsg { background: var(--ok-soft); color: var(--ok); border-radius: 10px; padding: 10px 14px; margin: 10px 0 0; font-weight: 600; }

/* ---------- מצבים ---------- */
.state { text-align: center; padding: 34px 20px; color: var(--muted); }
.state .big-ic { font-size: 2.4rem; display: block; margin-bottom: 6px; }
.state h2 { color: var(--ink); }
.done { text-align: center; padding: 30px 20px; }
.done .tick {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--ok-soft); color: var(--ok);
  display: grid; place-items: center; font-size: 34px; margin: 0 auto 10px;
}
.done h2 { font-size: 1.25rem; margin-bottom: 6px; }
.done p { color: var(--muted); margin: 0 0 16px; }

/* ---------- ניהול ---------- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 16px;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.brand img { width: 28px; height: 28px; }
.brand small { font-weight: 400; color: var(--muted); }
.tb-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 0 0 14px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.kpi .v { font-size: 1.6rem; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.kpi .l { color: var(--muted); font-size: .88rem; }
.kpi.ok .v { color: var(--ok); }
.kpi.warn .v { color: var(--warn); }
@media (max-width: 720px) { .kpis { grid-template-columns: repeat(2, 1fr); } }

.cols { display: grid; grid-template-columns: 1.1fr .9fr; gap: 14px; align-items: start; }
@media (max-width: 900px) { .cols { grid-template-columns: 1fr; } }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 0 0 12px; }
.toolbar input[type="search"] { flex: 1 1 200px; border: 1.5px solid var(--line); border-radius: 10px; padding: 8px 12px; min-width: 0; }
.seg { display: inline-flex; border: 1.5px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 7px 12px; cursor: pointer; font-size: .9rem; }
.seg button + button { border-inline-start: 1px solid var(--line); }
.seg button.on { background: var(--brand); color: #fff; }

table.list { width: 100%; border-collapse: collapse; font-size: .94rem; }
.list th { text-align: start; font-size: .82rem; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1.5px solid var(--line); white-space: nowrap; }
.list td { padding: 9px 8px; border-bottom: 1px solid #eceef3; vertical-align: middle; }
.list tr.new td { background: #fffbea; }
.list .acts { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.list .who b { display: block; }
.list .who small { color: var(--muted); }
.list .num { font-variant-numeric: tabular-nums; direction: ltr; text-align: right; }
.empty { text-align: center; color: var(--muted); padding: 26px 10px; }

.badge { display: inline-block; border-radius: 99px; padding: 1px 10px; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.badge.open { background: #eef0f5; color: #4d5568; }
.badge.seen { background: var(--warn-soft); color: var(--warn); }
.badge.signed { background: var(--ok-soft); color: var(--ok); }
.badge.revoked { background: var(--bad-soft); color: var(--bad); }
.badge.kind { background: var(--brand-soft); color: var(--brand); font-weight: 500; }

@media (max-width: 760px) {
  table.list thead { display: none; }
  table.list, .list tbody, .list tr, .list td { display: block; width: 100%; }
  .list tr { border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; margin-bottom: 10px; }
  .list td { border: 0; padding: 3px 0; }
  .list td[data-l]::before { content: attr(data-l) ": "; color: var(--muted); font-size: .85rem; }
  .list .acts { justify-content: flex-start; margin-top: 6px; }
}

.openlink { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.openlink code { flex: 1 1 260px; direction: ltr; text-align: left; background: #f6f7fa; border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; font-size: .82rem; overflow-wrap: anywhere; }
.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; margin: 8px 0; }
.switch input { width: 20px; height: 20px; accent-color: var(--brand); }
.allowed { display: flex; gap: 14px; flex-wrap: wrap; margin: 4px 0 6px; }
.allowed label { display: flex; gap: 6px; align-items: center; cursor: pointer; }
.allowed input { width: 18px; height: 18px; accent-color: var(--brand); }
details.card > summary { cursor: pointer; font-weight: 700; list-style: none; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::before { content: "◂ "; color: var(--muted); }
details.card[open] > summary::before { content: "▾ "; }
details.card[open] > summary { margin-bottom: 12px; }
.menu { position: relative; }
.menu-pop {
  position: absolute; top: calc(100% + 4px); inset-inline-end: 0; z-index: 10;
  min-width: 200px; background: #fff; border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 10px 30px rgba(20, 28, 50, .14); padding: 4px; display: grid;
}
.menu-pop button { border: 0; background: none; text-align: start; padding: 8px 10px; border-radius: 7px; cursor: pointer; font-size: .9rem; }
.menu-pop button:hover { background: #f1f3f8; }
.menu-pop button.danger { color: var(--bad); }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }

/* שם האתר (SITE_TITLE, השרת מכניס במקום <!--SITE-->) */
.site-name:empty { display: none; }
.doc-head .site-name { display: inline-block; font-weight: 700; color: var(--brand); background: var(--brand-soft); border-radius: 99px; padding: 2px 14px; font-size: .9rem; margin-bottom: 6px; }
.brand .site-name { color: var(--brand); }
.brand .site-name:not(:empty) + .brand-sub { font-weight: 400; color: var(--muted); font-size: .92rem; }
.login-site { color: var(--brand); font-weight: 700; margin: -6px 0 14px; }
@media (max-width: 560px) { .brand .site-name:not(:empty) + .brand-sub { display: none; } }

/* מעסיקים + מייל (20/10) */
.muted { color: var(--muted); }
small.muted, .muted.sm { font-size: .85rem; }
.sel { border: 1.5px solid var(--line); border-radius: 10px; padding: 7px 10px; background: #fff; max-width: 220px; }
.emp { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin: 0 0 10px; display: grid; gap: 6px; }
.emp-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.emp-head b { display: block; }
.emp-head small { color: var(--muted); }
.emp .openlink code { flex-basis: 180px; }
.list .who small.mailst { display: block; color: var(--ok); font-size: .82rem; }
.list .who small.mailst.bad { color: var(--bad); }
.warnbar { background: var(--warn-soft); color: var(--warn); border: 1px solid #f0d9ae; border-radius: 12px; padding: 10px 14px; margin: 0 0 14px; font-weight: 600; }
.mailbox p { margin: 0 0 6px; font-size: .92rem; }
.okline { color: var(--ok); font-weight: 600; }
.warnline { color: var(--warn); font-weight: 600; }
dialog .row .grow { flex: 1; }
dialog { width: min(520px, calc(100% - 32px)); }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: min(380px, 100%); }
.login h1 { font-size: 1.2rem; margin: 0 0 14px; display: flex; gap: 10px; align-items: center; }
.login h1 img { width: 30px; }

.toast {
  position: fixed; bottom: 18px; left: 50%; transform: translate(-50%, 20px);
  background: #1b2233; color: #fff; padding: 10px 18px; border-radius: 10px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

dialog { border: 0; border-radius: var(--radius); padding: 20px; width: min(420px, calc(100% - 32px)); box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
dialog::backdrop { background: rgba(20, 28, 50, .35); }
dialog h3 { margin: 0 0 12px; }
dialog .row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media (max-width: 480px) {
  .card, .wrap.form .card { padding: 16px 14px 14px; }
  .doc-head h1 { font-size: 1.18rem; }
}
