.contract-composer {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.contract-composer-bar {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding-bottom: 11px;
  margin-bottom: 3px;
  border-bottom: 1px solid var(--line);
}

.contract-composer-bar .field {
  flex: 1 1 12rem;
  max-width: 23rem;
}

#full-contract-text {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 16rem;
  height: clamp(20rem, 56vh, 38rem);
  padding: 1rem;
  resize: vertical;
  direction: rtl;
  overflow-wrap: anywhere;
  border: 1px solid #424242;
  border-radius: 12px;
  background: #151515;
  color: var(--text);
  font-size: 1rem;
  line-height: 2;
  text-align: right;
}

#full-contract-text::placeholder {
  color: var(--muted);
}

#contract-text-help {
  margin: 0;
  color: var(--muted);
  font-size: .82rem;
  line-height: 1.6;
}

@media (max-width: 680px) {
  .contract-composer-bar .field {
    flex-basis: 9rem;
  }

  #full-contract-text {
    height: clamp(16rem, 51vh, 30rem);
    padding: .7rem;
  }
}

.payment-editor { display: grid; gap: 12px; margin-block-start: 20px; }
.payment-editor h3 { margin: 0; font-size: 1rem; }
.payment-editor > .btn, .payment-row > .btn { justify-self: start; }
.payment-row { display: grid; gap: 10px; min-inline-size: 0; border: 1px solid #555; padding: 12px; border-radius: 10px; }
.payment-row .field-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.paper-preview .office-document { display: grid; gap: 8px; min-inline-size: 0; }
.paper-preview .office-document :is(p, h4, h5) { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.paper-preview .office-document .heading { margin-block-start: 10px; }
.paper-preview .office-document .eyebrow { text-align: center; }
.paper-preview .office-document .small { font-size: .82em; }
.paper-preview .office-table-wrap { max-inline-size: 100%; overflow-x: auto; }
.paper-preview .office-document-table { width: 100%; min-inline-size: 305px; border-collapse: collapse; table-layout: fixed; color: #242424; font-size: .8em; }
.paper-preview .office-document-table:has(th:nth-child(6)) { min-inline-size: 500px; }
.paper-preview .office-document-table :is(td, th) { padding: 5px; border: 1px solid #a1a1a1; text-align: right; vertical-align: top; background: white; white-space: pre-wrap; overflow-wrap: anywhere; }
.paper-preview .office-document-table th { background: #ececec; color: #242424; }
.paper-preview .office-signatures td { height: 70px; }
@media (max-width: 560px) {
  .payment-row .field-grid { grid-template-columns: 1fr; }
}

@font-face {
  font-family: ContractNazanin;
  src: url('/fonts/contract-nazanin-regular.ttf') format('truetype');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: ContractNazanin;
  src: url('/fonts/contract-nazanin-bold.ttf') format('truetype');
  font-weight: 700;
  font-display: swap;
}

.office-logo-settings { max-width: 36rem; }
.office-logo-settings .panel-body { display: grid; gap: 20px; }
.office-brand-preview { display: grid; justify-items: start; gap: 8px; font-size: .84rem; color: var(--muted); }
.office-brand-preview img { width: 158px; height: 120px; object-fit: contain; border-radius: 7px; background: white; filter: grayscale(1); }
.office-logo-form { display: grid; gap: 10px; }
.office-paper .office-document { display: block; }
.office-preview-header { display: grid; grid-template-columns: 22% 50% 28%; border: 1px solid #444; align-items: stretch; }
.office-preview-header > * { padding: 4px; min-width: 0; }
.office-preview-header > * + * { border-inline-start: 1px solid #444; }
.office-preview-title { text-align: center; align-content: center; }
.office-preview-title p { font-size: .68em; }
.office-preview-title h3 { font-size: .94em; margin: 3px 0 0; line-height: 1.45; }
.office-preview-logo { display: grid; place-content: center; }
.office-preview-logo img { width: 100%; max-height: 74px; object-fit: contain; filter: grayscale(1); }
.office-preview-header dl { margin: 0; font-size: .63em; }
.office-preview-header dl div { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 2px 4px; overflow-wrap: anywhere; }
.office-preview-header dd { margin: 0; font-weight: 700; }
.office-paper .office-paper-section { margin: 0; padding: 4px; border: 1px solid #444; border-block-start: 0; }
.office-paper .office-paper-section.office-article-shaded { background: #f1f1f1; }
.office-paper .office-paper-section .heading { margin: 0 0 2px; font-size: .87em; }
.office-paper .office-paper-section .body-text { text-align: justify; font-size: .85em; }
.office-paper .office-paper-section .agency { font-size: .76em; }
.office-paper .office-paper-section .office-table-wrap { margin-block: 2px 5px; }

.contract-composer-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.contract-composer-actions .btn[aria-pressed="true"], .contract-composer-actions .btn[aria-expanded="true"] { border-color: var(--green-text); }
.contract-composer-search { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: end; gap: 7px 10px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; }
.contract-composer-search [role="status"] { grid-column: 1 / -1; margin: 0; }
.contract-composer-search [role="status"]:empty { display: none; }
.editor-grid.expanded-contract-editor { grid-template-columns: minmax(0, 1fr); }
.expanded-contract-editor #full-contract-text { min-height: 58vh; }
.office-preview-title img { display: block; width: 100%; max-height: 72px; object-fit: contain; }

.editor-grid.office-document-layout { grid-template-columns: minmax(0, 1fr); }
.document-views { margin-bottom: 14px; }
.document-controls { display: grid; gap: 8px; margin: 0 auto 14px; max-width: 56rem; }
.document-controls p { margin: 0; }
.office-edit-sheet { color: #1a1a1a; background: #fefefd; max-width: 56rem; margin-inline: auto; padding: clamp(8px, 3vw, 25px); border-radius: 3px; box-shadow: 0 15px 30px #0004; line-height: 1.8; }
.office-edit-sheet .office-preview-header { min-height: 98px; }
.office-edit-sheet .office-preview-header dl { font-size: clamp(.58rem, 1.1vw, .74rem); }
.office-edit-sheet .office-paper-section { padding: 7px 8px; }
.office-edit-sheet .office-document-table { width: 100%; min-width: 365px; border-collapse: collapse; table-layout: fixed; font-size: .75rem; color: #222; }
.office-edit-sheet .office-document-table:has(th:nth-child(8)) { min-width: 510px; }
.office-edit-sheet .office-table-wrap { overflow-x: auto; }
.office-edit-sheet .office-document-table :is(td,th) { border: 1px solid #666; padding: 3px; text-align: center; background: #fff; white-space: pre-wrap; overflow-wrap: anywhere; }
.office-edit-sheet .office-document-table th { background: #eee; }
.office-edit-sheet :is(h4,h5,p) { margin: 0; }
.office-edit-sheet .document-heading, .office-edit-sheet .document-body { color: #171717; background: transparent; border: 1px solid transparent; border-radius: 3px; width: 100%; padding: 4px; margin: 0; }
.office-edit-sheet .document-heading { font-size: .91rem; font-weight: 750; }
.office-edit-sheet .document-body { font-size: .87rem; white-space: pre-wrap; overflow-wrap: anywhere; text-align: justify; line-height: 1.95; }
.office-edit-sheet .document-body:empty:not(:focus) { display: none; }
.office-edit-sheet .document-article .document-body[data-empty-slot]:empty, .office-edit-sheet .document-article:focus-within .document-body:empty { display: block; }
.office-edit-sheet .document-body:empty::before { content: attr(data-placeholder); color: #626262; pointer-events: none; }
.office-edit-sheet :is(.document-body,.document-heading):is(:hover,:focus) { border-color: #72907b; outline: none; background: #fbfff8; }
.document-variable { background: #e5eee6; border-radius: 3px; padding: 1px 2px; }
.document-article-tools { display: flex; align-items: center; justify-content: flex-end; gap: 7px; margin-block-start: 4px; }
.document-tool { background: #ededed; color: #323232; border: 1px solid #bbb; border-radius: 5px; min-height: 30px; padding: 3px 8px; font-size: .73rem; cursor: pointer; }
.document-tool:focus-visible { outline: 2px solid #397751; outline-offset: 2px; }
.document-remove { color: #6d302a; }
@media (max-width: 560px) {
  .office-edit-sheet .office-paper-section { padding: 3px; }
  .office-edit-sheet .document-heading { font-size: .81rem; }
  .document-tool { min-height: 42px; }
}
.office-paper .office-document-table { display: table; }
.office-paper .office-document-table thead { display: table-header-group; }
.office-paper .office-document-table tbody { display: table-row-group; }
.office-paper .office-document-table tr { display: table-row; }
.office-document-layout .editor-main > .editor-panel:first-child { overflow: visible; }
.office-document-layout .document-controls { position: sticky; top: 5px; z-index: 2; padding: 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.office-document-layout .editor-main { grid-template-columns: minmax(0, 1fr); }
.office-document-layout .editor-main > .editor-panel:first-child { min-width: 0; }

.document-variable, .document-cell-edit { color: #255038; border: 0; text-align: inherit; cursor: pointer; font: inherit; }
.document-variable:focus-visible, .document-cell-edit:focus-visible { outline: 2px solid #397751; outline-offset: 1px; }
.document-cell-edit { background: #edf4ed; width: 100%; min-height: 25px; border-radius: 3px; padding: 1px; white-space: pre-wrap; overflow-wrap: anywhere; }
.document-help { color: var(--muted); font-size: .83rem; }
.document-help summary { cursor: pointer; }
.document-help ol { margin: 5px 0 0; padding-inline-start: 22px; }
.document-article-tools { flex-wrap: wrap; }
.variable-dialog, .variable-new-fields, .custom-field { display: grid; gap: 10px; }
.variable-dialog { margin-block-start: 12px; }
.variable-dialog .inline-actions { flex-wrap: wrap; }
.custom-field .btn { justify-self: start; }
.office-edit-sheet :is(button, [data-office-body]) { scroll-margin-block-start: 125px; }
.document-cell-edit { box-sizing: border-box; display: block; min-width: 0; cursor: text; text-align: center; }
.document-cell-edit::placeholder { color: #637468; }

.office-paper { font-family: ContractNazanin, Vazirmatn, sans-serif; }
.office-preview-title p { font-size: .88em; font-weight: 700; }
.office-preview-title h3 { font-size: 1.22em; }

.office-preview-title p { line-height: 1.55; }
.office-preview-title h3 { margin-block-start: .4em; line-height: 1.25; }

.segmented-date {
  display: grid;
  grid-template-columns: minmax(48px, 1.5fr) auto minmax(30px, 1fr) auto minmax(30px, 1fr);
  gap: 3px;
  align-items: center;
  min-width: 0;
}
.segmented-date input[data-date-part] { padding-inline: 2px; text-align: center; }
.office-edit-sheet .segmented-date { gap: 1px; grid-template-columns: minmax(0, 1.5fr) auto minmax(0, 1fr) auto minmax(0, 1fr); }
.office-edit-sheet .segmented-date input[data-date-part] {
  width: 100%; min-width: 0; border: 1px solid transparent; padding: 0; color: #161616; background: transparent; font: inherit;
}

.editable-variable { position: relative; min-width: 0; padding-inline-end: 34px; }
.editable-variable.wide { grid-column: 1 / -1; }
.field-remove { position: absolute; inset-inline-end: 0; top: 1.55rem; min-width: 30px; min-height: 35px; padding: 4px; }
.field-remove .icon { width: 15px; height: 15px; }
.add-form-field { margin-block-start: 10px; }
.document-cell-control { display: flex; align-items: center; gap: 2px; min-width: 0; }
.document-cell-control > :first-child { flex: 1; min-width: 0; }
.cell-remove { flex: none; cursor: pointer; padding: 1px 3px; border: 1px solid #ddd; border-radius: 4px; background: #fff; color: #6c302a; }
.document-table-tools { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 5px; padding: 3px; }

.office-paper .office-document-table td,
.office-paper .office-document-table th { color: #1b1b1b; }
.office-edit-sheet .office-document-table { font-size: .9rem; }
.office-edit-sheet .office-document-table :is(.document-cell-edit, [data-date-part]) { font-weight: 700; }
.office-edit-sheet .office-document-table .payment-currency { flex: none; font-weight: 700; }
.office-edit-sheet .payment-row-action .document-tool { padding-inline: 3px; min-width: 0; }
.paper-preview .office-document-table[data-office-table="payment"] { font-size: .95em; }
