@font-face {
  font-family: 'Fredoka';
  src: url('/fonts/fredoka-hebrew.woff2') format('woff2');
  font-weight: 300 700;
  font-display: swap;
  unicode-range: U+0307-0308, U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F;
}
@font-face {
  font-family: 'Fredoka';
  src: url('/fonts/fredoka-latin.woff2') format('woff2');
  font-weight: 300 700;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --purple: #4D3571;
  --mauve: #B983B7;
  --mauve-soft: #F6EEF6;
  --ink: #161B2C;
  --muted: #68607A;
  --line: #E4DEEA;
  --page-bg: #F4F1F7;
  --bad: #B3261E;
  --good: #2E7D5B;
  --warn: #A8650B;
  --font: 'Fredoka', 'Assistant', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
}

* { box-sizing: border-box; }
html.scroll-locked, html.scroll-locked body { overscroll-behavior: none; touch-action: none; }
html.modal-open, html.modal-open body { overflow: hidden; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--page-bg); font-size: 16px; line-height: 1.5; }
h1, h2, h3 { color: var(--purple); font-weight: 600; margin: 0; line-height: 1.25; }
a { color: var(--purple); }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.loading { text-align: center; padding: 80px 16px; color: var(--muted); }

/* ---------- buttons and form controls ---------- */
.btn { font: inherit; font-weight: 500; border: 1px solid var(--line); background: #fff; color: var(--purple); border-radius: 10px; padding: 9px 16px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; }
.btn:hover:not(:disabled) { border-color: var(--mauve); background: var(--mauve-soft); }
.btn:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 2px solid var(--mauve); outline-offset: 1px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--purple); border-color: var(--purple); color: #fff; }
.btn.primary:hover:not(:disabled) { background: #3e2a5c; border-color: #3e2a5c; }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 12px; min-height: 34px; font-size: 14px; }
.btn.big { padding: 12px 28px; font-size: 18px; min-height: 52px; }
.btn.danger { color: var(--bad); }
.btn.danger:hover:not(:disabled) { background: #FBEDEC; border-color: var(--bad); }

input[type=text], input[type=number], input[type=date], input[type=time], input[type=password], input[type=url], input:not([type]), textarea, select {
  font: inherit; color: inherit; width: 100%; background: #fff; border: 1px solid #CFC7D9; border-radius: 9px; padding: 9px 12px; min-height: 44px;
}
textarea { resize: vertical; line-height: 1.45; }
input.invalid, textarea.invalid { border-color: var(--bad); }
input[type=checkbox] { accent-color: var(--purple); width: 20px; height: 20px; flex: none; margin: 0; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > span:first-child { font-size: 14px; font-weight: 500; color: var(--purple); }
.field.wide { grid-column: 1 / -1; }
.field-error { color: var(--bad); font-size: 14px; min-height: 0; margin: 0; }
.field-error:empty { display: none; }
.hint { font-size: 14px; color: var(--muted); margin: 4px 0 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 10px; z-index: 100; max-width: calc(100vw - 32px); }
.toast.bad { background: var(--bad); }

/* ---------- the agreement sheet (A4 at 96dpi: 794 x 1123) ---------- */
.pages { display: flex; flex-direction: column; align-items: center; gap: 22px; }
.sheet { width: 794px; height: 1123px; background: #fff; box-shadow: 0 2px 14px rgba(77, 53, 113, .14); display: flex; flex-direction: column; padding: 18px 44px 12px; flex: none; overflow: hidden; color: var(--ink); font-size: 14.5px; line-height: 1.55; }
.sheet-header { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 18px; flex: none; height: 92px; }
.head-side { display: flex; flex-direction: column; gap: 4px; justify-content: flex-end; border-bottom: 1px solid #D3D3D3; padding-bottom: 8px; align-self: end; }
.head-logo { width: 158px; height: auto; display: block; }
.contact-row { display: flex; align-items: center; gap: 7px; font-size: 11.5px; color: #4f4f5c; }
.ci { width: 17px; height: 17px; border-radius: 50%; background: var(--mauve); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.ci svg { width: 11px; height: 11px; display: block; }
.sheet-body { flex: 1 1 0; min-height: 0; overflow: hidden; padding-top: 14px; }
.sheet-footer { flex: none; height: 72px; border-top: 1px solid #C9C4D2; display: flex; justify-content: center; align-items: center; margin-top: 6px; }
.sheet-footer img { width: 50px; height: 50px; display: block; }

.client-line { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 10px; }
.agr-title { font-size: 25px; text-align: center; font-weight: 700; margin: 6px 0 4px; }
.agr-intro { text-align: center; margin: 0 0 12px; font-weight: 500; }

.bubble { position: relative; border: 1.5px solid var(--purple); border-radius: 13px 13px 13px 13px; text-align: center; color: var(--purple); font-size: 20px; font-weight: 500; line-height: 1.2; padding: 3px 16px; margin: 16px 0 18px; background: #fff; }
.bubble .tail { position: absolute; bottom: -12.5px; width: 20px; height: 14px; display: block; }
.bubble.tail-right .tail { right: 12px; }
.bubble.tail-left .tail { left: 12px; }

.agr-table { width: 100%; border-collapse: collapse; margin-bottom: 6px; table-layout: fixed; }
.agr-table th { background: var(--mauve); color: #fff; font-weight: 600; padding: 5px 10px; border: 1px solid var(--ink); text-align: center; font-size: 14.5px; }
.agr-table td { padding: 6px 10px; border: 1px solid var(--ink); vertical-align: top; text-align: right; font-size: 13.5px; line-height: 1.45; }
.agr-table .c-product { width: 27%; }
.agr-table .c-notes { width: 52%; }
.agr-table .c-price { width: 21%; text-align: center; font-weight: 600; }
.agr-table th.c-price, .agr-table th.c-product, .agr-table th.c-notes { text-align: center; }
.total-row td { font-weight: 700; }
.footnote { font-size: 11.5px; text-align: center; margin: 2px 0 10px; }
.total-line { margin: 4px 0; }

.clause { display: flex; gap: 9px; margin: 0 0 7px; padding-inline-start: 14px; }
.clause .dot { width: 5px; height: 5px; background: var(--ink); border-radius: 50%; margin-top: 9px; flex: none; }
.clause > div { min-width: 0; }

.signature-block { margin-top: 12px; }
.closing { text-align: center; font-weight: 500; margin: 0 0 12px; }
.client-notes { margin: 0 0 12px; font-size: 13.5px; }
.sig-grid { display: grid; grid-template-columns: 1.55fr 1fr; gap: 30px; }
.sig-who { font-weight: 600; color: var(--purple); margin-bottom: 6px; }
.sig-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; }
.sig-label { color: var(--mauve); font-weight: 600; font-size: 14px; }
.sig-value { border-bottom: 1px solid var(--purple); min-height: 26px; font-size: 13.5px; overflow-wrap: anywhere; }
.sig-mark { margin-top: 8px; }
.sig-image { border-bottom: 1px solid var(--purple); height: 74px; display: flex; align-items: center; justify-content: center; }
.sig-image img { max-height: 70px; max-width: 100%; display: block; }
.sig-date { margin-top: 6px; font-size: 13.5px; }
.audit-line { font-size: 10.5px; color: var(--muted); margin: 12px 0 0; text-align: center; overflow-wrap: anywhere; }

.sign-slot { margin-top: 8px; }
.pad-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.pad-frame { position: relative; height: 130px; border: 1px dashed var(--mauve); border-radius: 10px; background: #FDFBFD; overflow: hidden; }
.sig-canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; display: block; z-index: 1; }
.pad-line { position: absolute; bottom: 26px; left: 16px; right: 16px; border-bottom: 1px solid var(--purple); }
.pad-hint { position: absolute; bottom: 4px; width: 100%; text-align: center; font-size: 12px; color: var(--muted); }
.has-ink .pad-hint { display: none; }
.accept { display: flex; align-items: center; gap: 9px; margin: 12px 0; cursor: pointer; font-weight: 500; }
.sign-slot .btn.big { width: 100%; }

.services-grid { display: flex; justify-content: space-between; align-items: center; gap: 22px; margin-top: 26px; }
.service-col { display: flex; flex-direction: column; gap: 46px; width: 208px; }
.service-card { position: relative; border: 1.5px solid var(--purple); border-radius: 76px; padding: 24px 14px 30px; text-align: center; background: #fff; }
.service-card .tail { position: absolute; width: 30px; height: 22px; display: block; }
.service-card.strategy .tail { bottom: -20px; left: 58px; transform: rotate(10deg); }
.service-card.branding .tail { bottom: -20px; right: 58px; transform: rotate(-10deg); }
.service-card.sites .tail { top: -20px; left: 58px; transform: rotate(170deg); }
.service-card.automation .tail { top: -20px; right: 58px; transform: rotate(190deg); }
.service-card.digital .tail { top: -20px; right: 58px; transform: rotate(190deg); }
.service-card .service-icon { width: 38px; height: 38px; display: block; margin: 0 auto 4px; }
.service-card h3 { font-size: 16.5px; padding-bottom: 8px; margin-bottom: 4px; border-bottom: 1.5px solid var(--mauve); display: inline-block; min-width: 60%; }
.service-card p { margin: 0 8px; padding: 6px 0; font-size: 13px; line-height: 1.3; }
.service-card p + p { border-top: 1px solid var(--mauve); }

/* Below 840px the sheet reflows at reading size instead of shrinking an A4 to 7px text. */
.sheet.fluid { width: 100%; height: auto; padding: 14px 16px 10px; font-size: 15.5px; overflow: visible; }
.sheet.fluid .sheet-header { grid-template-columns: 1fr 1fr; height: auto; gap: 8px 12px; }
.sheet.fluid .head-logo { grid-column: 1 / -1; grid-row: 1; justify-self: center; width: 118px; }
.sheet.fluid .head-side { border-bottom: 0; padding-bottom: 0; align-self: start; }
.sheet.fluid .contact-row { font-size: 11px; overflow-wrap: anywhere; }
.sheet.fluid .sheet-body { overflow: visible; flex: none; }
.sheet.fluid .sheet-footer { margin-top: 18px; }
.sheet.fluid .agr-table, .sheet.fluid .agr-table tbody { display: block; }
.sheet.fluid .agr-table thead { display: none; }
.sheet.fluid .agr-table tr { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; border: 1px solid var(--mauve); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; }
.sheet.fluid .agr-table td { border: 0; padding: 0; font-size: 14.5px; width: auto; }
.sheet.fluid .agr-table .c-notes { grid-column: 1 / -1; grid-row: 2; }
.sheet.fluid .agr-table .c-notes:empty { display: none; }
.sheet.fluid .agr-table .c-price { grid-column: 2; grid-row: 1; color: var(--purple); text-align: left; }
.sheet.fluid .total-row { background: var(--mauve-soft); }
.sheet.fluid .sig-grid { grid-template-columns: 1fr; gap: 22px; }
.sheet.fluid .bubble { font-size: 18px; }
.sheet.fluid .services-grid { flex-direction: column; gap: 18px; }
.sheet.fluid .service-col { width: 100%; max-width: 300px; gap: 18px; }

.pdf-host { position: fixed; top: 0; left: -20000px; width: 794px; }
.pdf-host .sheet { box-shadow: none; }

/* ---------- client signing page ---------- */
.sign-page { padding: 22px 16px 60px; display: flex; flex-direction: column; align-items: center; gap: 22px; }
.sign-page .pages { width: 100%; }
.details-card { width: 100%; max-width: 794px; background: #fff; border-radius: 14px; padding: 20px; box-shadow: 0 2px 14px rgba(77, 53, 113, .1); }
.details-card h2 { font-size: 20px; }
.details-card .muted { margin: 2px 0 14px; }
.signed-banner { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; }
.signed-banner .muted { margin: 0; }
.center-card { max-width: 480px; margin: 8vh auto; background: #fff; border-radius: 16px; padding: 34px 24px; text-align: center; box-shadow: 0 2px 14px rgba(77, 53, 113, .12); display: flex; flex-direction: column; align-items: center; gap: 8px; width: calc(100% - 32px); }
.center-logo { width: 130px; margin-bottom: 10px; }
.center-card p { margin: 0; }
.center-card .btn { margin-top: 14px; }
.sign-signature { font-weight: 600; color: var(--purple); }

@media (max-width: 839px) {
  .sign-page { padding: 12px 10px 40px; }
}
@media (max-width: 560px) {
  .form-grid { grid-template-columns: 1fr; }
}

/* ---------- admin ---------- */
.topbar { background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 14px; padding: 8px 20px; position: sticky; top: 0; z-index: 20; flex-wrap: wrap; }
.topbar img { height: 36px; display: block; }
.topbar nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.topbar nav a { text-decoration: none; padding: 7px 12px; border-radius: 8px; font-weight: 500; }
.topbar nav a.active { background: var(--mauve-soft); }
.wrap { max-width: 1040px; margin: 0 auto; padding: 22px 20px 110px; }
.wrap h1 { font-size: 26px; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.card { background: #fff; border-radius: 14px; padding: 20px; margin-bottom: 16px; box-shadow: 0 1px 6px rgba(77, 53, 113, .08); }
.card > h2 { font-size: 18px; margin-bottom: 12px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { font-size: 18px; }

.login { max-width: 380px; margin: 12vh auto; background: #fff; border-radius: 16px; padding: 30px 24px; box-shadow: 0 2px 14px rgba(77, 53, 113, .12); width: calc(100% - 32px); display: flex; flex-direction: column; gap: 14px; }
.login img { width: 130px; align-self: center; }

.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.chip { font: inherit; border: 1px solid var(--line); background: #fff; color: var(--purple); border-radius: 999px; padding: 6px 14px; cursor: pointer; min-height: 38px; }
.chip.on { background: var(--purple); border-color: var(--purple); color: #fff; }
.search { margin-bottom: 14px; }
.agreement-row { background: #fff; border-radius: 12px; padding: 14px 16px; margin-bottom: 10px; box-shadow: 0 1px 6px rgba(77, 53, 113, .08); }
.row-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; flex-wrap: wrap; }
.row-name { font-weight: 600; font-size: 17px; color: var(--purple); text-decoration: none; }
.row-meta { font-size: 14px; color: var(--muted); }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.badge { display: inline-block; padding: 2px 11px; border-radius: 999px; font-size: 13.5px; font-weight: 500; white-space: nowrap; }
.badge.draft { background: #EEECF1; color: #57506A; }
.badge.pending { background: #FBF0DC; color: var(--warn); }
.badge.viewed { background: var(--mauve-soft); color: #7D4A7B; }
.badge.signed { background: #E2F3EA; color: var(--good); }
.badge.expired { background: #FBEDEC; color: var(--bad); }
.edited-flag { color: var(--warn); font-size: 13.5px; font-weight: 500; }
.empty { text-align: center; padding: 50px 16px; color: var(--muted); background: #fff; border-radius: 14px; }

.switch { display: flex; align-items: center; gap: 9px; cursor: pointer; font-weight: 500; }
.row-editor { border: 1px solid var(--line); border-radius: 11px; padding: 12px; margin-bottom: 10px; }
.row-editor.off { background: #FAF9FB; }
.row-editor.off .row-body { display: none; }
.row-title { display: flex; align-items: center; gap: 9px; }
.row-title input[type=text], .row-title input:not([type]) { flex: 1; min-width: 0; font-weight: 500; }
.row-body { margin-top: 9px; display: flex; flex-direction: column; gap: 9px; }
.price-grid { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 10px; align-items: center; }
.qty-input { width: 78px !important; flex: none; }
.segments { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.amount-input { max-width: 200px; }
.inline-note { font-size: 14px; color: var(--muted); }
.computed { margin: 6px 0 0; font-weight: 500; color: var(--purple); font-size: 15px; }

.clause-section { border: 1px solid var(--line); border-radius: 11px; padding: 12px; margin-bottom: 12px; background: #fff; }
.section-head { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.section-head input { font-weight: 600; color: var(--purple); }
.clause-item { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 8px; background: #fff; }
.clause-item textarea { flex: 1; min-width: 0; }
.handle { cursor: grab; color: var(--mauve); user-select: none; font-size: 20px; line-height: 44px; width: 26px; text-align: center; flex: none; touch-action: none; }
.icon-btn { font: inherit; border: 0; background: transparent; color: var(--bad); cursor: pointer; width: 34px; height: 44px; flex: none; font-size: 18px; border-radius: 8px; }
.icon-btn:hover { background: #FBEDEC; }
.sortable-ghost { opacity: .4; }

.actions-bar { position: fixed; bottom: 0; right: 0; left: 0; background: #fff; border-top: 1px solid var(--line); padding: 10px 20px; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; z-index: 20; }
.link-box { background: var(--mauve-soft); border-radius: 12px; padding: 14px; margin-bottom: 16px; }
.link-box code { display: block; direction: ltr; text-align: left; overflow-wrap: anywhere; font-size: 13px; background: #fff; padding: 8px 10px; border-radius: 8px; margin: 8px 0; font-family: ui-monospace, Menlo, monospace; }
.link-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 22px; margin: 0; }
.facts div { min-width: 0; }
.facts dt { font-size: 13.5px; color: var(--muted); }
.facts dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.edit-list { margin: 0; padding: 0; list-style: none; }
.edit-list li { padding: 7px 0; border-bottom: 1px solid var(--line); }
.edit-list li:last-child { border-bottom: 0; }
.edit-list del { color: var(--muted); }
.edit-list ins { text-decoration: none; font-weight: 600; background: #FBF0DC; padding: 0 4px; border-radius: 4px; }
.view-pages { margin-top: 8px; }

.modal { position: fixed; inset: 0; background: rgba(22, 27, 44, .55); z-index: 50; overflow-y: auto; padding: 16px 10px 40px; }
.modal-bar { max-width: 794px; margin: 0 auto 12px; display: flex; justify-content: space-between; align-items: center; color: #fff; font-weight: 500; }

.asset-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.asset-row img { height: 64px; max-width: 170px; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 4px; }

@media (max-width: 640px) {
  .wrap { padding: 14px 12px 130px; }
  .facts { grid-template-columns: 1fr; }
  .price-grid { grid-template-columns: 1fr; }
  .topbar { padding: 8px 12px; }
  .actions-bar { padding: 8px 10px; }
  .actions-bar .btn { flex: 1 1 40%; padding: 8px; }
}
@media print {
  body { background: #fff; }
}
