/*
 * WITH BUILDERS — نظام المستندات v2 (مذكرات التفاهم، وثيقة السفراء، بطاقة السفير).
 * مأخوذ من مستندات حزمة التسليم («اتفاق فريق رواد الأثر»): خلفية دافئة، شريط أزرار،
 * بطاقة بيضاء بعرض 720، الشعار نصًا أحمر فوق العنوان، وعناوين الأقسام بالأحمر.
 * الطباعة: A4، بلا شريط الأزرار ولا إطار البطاقة، والأقسام لا تنقسم بين صفحتين.
 */
@font-face { font-family: 'Thmanyah Sans'; src: url("/assets/fonts/thmanyahsans-Regular.woff2") format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Thmanyah Sans'; src: url("/assets/fonts/thmanyahsans-Bold.woff2") format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Thmanyah Sans'; src: url("/assets/fonts/thmanyahsans-Black.woff2") format('woff2'); font-weight: 900; font-display: swap; }

:root {
  --red: #E12F34; --red-text: #BC2126; --red-hover: #B21F26; --red-on-dark: #FF8A8D;
  --ink: #16130F; --paper: #FBFAF8; --warm: #F7F5F1; --tint: #FBECEA; --tint-line: #F2CFCC;
  --line: #E7E2DB; --line-2: #F1EDE8; --line-3: #CFC8C0; --muted: #6E6862; --faint: #9A938C;
  --dark-body: #D9D3CC;
}
* { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
html, body { margin: 0; padding: 0; }
body { background: var(--warm); color: var(--ink); font-family: 'Thmanyah Sans', 'Helvetica Neue', sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--red-text); text-decoration: none; }
a:hover { color: var(--red-hover); }
button { font-family: inherit; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
[hidden] { display: none !important; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.nowrap { white-space: nowrap; }

.doc-wrap { padding: 40px 16px 80px; }

/* شريط الأزرار فوق المستند */
.doc-tools { max-width: 720px; margin: 0 auto 16px; display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.pill { height: 46px; padding: 0 22px; border-radius: 999px; font-size: 15px; font-weight: 900; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box; font-family: inherit; text-decoration: none; transition: background-color .15s, color .15s; }
.pill-red { border: 0; background: var(--red); color: #fff; }
.pill-red:hover { background: var(--ink); color: #fff; }
.pill-outline { border: 1.5px solid var(--ink); background: #fff; color: var(--ink); }
.pill-outline:hover { background: var(--ink); color: #fff; }

/* المستند */
.doc { max-width: 720px; margin: 0 auto; background: #fff; border: 1px solid var(--line); border-radius: 26px; padding: clamp(28px, 6vw, 56px); display: flex; flex-direction: column; gap: 22px; box-sizing: border-box; }
.doc-wide { max-width: 860px; }
.doc-head { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.doc-mark { font-size: 20px; font-weight: 900; letter-spacing: 0.04em; color: var(--red); direction: ltr; }
.doc h1 { font-size: clamp(26px, 5vw, 36px); font-weight: 900; line-height: 1.3; margin: 0; text-wrap: balance; }
.doc-sub { font-size: 16px; font-weight: 700; color: var(--red-text); margin: 0; }
.doc-meta { font-size: 14px; color: var(--muted); margin: 0; }
.doc p { font-size: 16px; line-height: 1.9; margin: 0; }
.doc .muted { color: var(--muted); }
.doc .lead { font-size: 17px; line-height: 1.9; }

/* الأقسام المرقّمة */
.doc-secs { display: flex; flex-direction: column; gap: 22px; }
.doc-sec { display: flex; flex-direction: column; gap: 8px; }
.doc-sec > h2, .doc h2.sec-title { font-size: 18px; font-weight: 900; color: var(--red-text); margin: 0; line-height: 1.5; }
.doc h3 { font-size: 16px; font-weight: 900; margin: 0; }
.doc ul, .doc ol { margin: 0; padding-right: 22px; padding-left: 0; font-size: 16px; line-height: 1.9; }
.doc li + li { margin-top: 2px; }

/* حقول التعبئة */
.fields { display: flex; flex-direction: column; gap: 14px; }
.field-line { display: grid; grid-template-columns: minmax(110px, auto) 1fr; align-items: end; gap: 12px; font-size: 15px; }
.field-line .k { font-weight: 700; color: var(--ink); white-space: nowrap; }
.field-line .v { border-bottom: 1px dotted var(--line-3); min-height: 26px; }
.blank { border-bottom: 1px dotted var(--line-3); min-height: 30px; }
.blank + .blank { margin-top: 6px; }

/* الجداول */
.doc table { width: 100%; border-collapse: collapse; font-size: 15px; line-height: 1.7; }
.doc th { background: var(--ink); color: #fff; font-weight: 900; text-align: right; padding: 10px 14px; }
.doc td { border-bottom: 1px solid var(--line-2); padding: 10px 14px; vertical-align: top; }
.doc td.num { color: var(--red); font-weight: 900; text-align: center; white-space: nowrap; background: var(--tint); }
.doc tr.side th { width: 120px; vertical-align: top; }

/* الصناديق */
.box { border: 1px solid var(--line); border-radius: 18px; padding: 18px 20px; background: var(--warm); display: flex; flex-direction: column; gap: 8px; }
.box-tint { background: var(--tint); border-color: var(--tint-line); }
.box-ink { background: var(--ink); border-color: var(--ink); color: #fff; }
.box-ink p, .box-ink li { color: var(--dark-body); }
.box .box-title { font-size: 16px; font-weight: 900; color: var(--red-text); }
.box-ink .box-title { color: var(--red-on-dark); }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: 14px; }

/* التوقيع */
.sig { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 18px; border-top: 1px solid var(--line); padding-top: 22px; font-size: 15px; color: var(--muted); }
.sig > div { display: flex; flex-direction: column; gap: 22px; }
.sig .line { border-bottom: 1px solid var(--line-3); min-height: 1px; }
.sig-party { font-weight: 900; color: var(--ink); }

/* تذييل المستند */
.doc-foot { border-top: 1px solid var(--line); padding-top: 14px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 13px; color: var(--faint); }
.doc-back { max-width: 720px; margin: 18px auto 0; text-align: center; font-size: 14px; color: var(--muted); }

@media print {
  @page { size: A4; margin: 14mm 14mm 16mm; }
  body { background: #fff; }
  .doc-wrap { padding: 0; }
  .doc-tools, .doc-back, .no-print { display: none !important; }
  .doc { border: 0; border-radius: 0; padding: 0; max-width: none; gap: 16px; }
  .doc-sec, .box, .sig, .field-line, tr, .keep { break-inside: avoid; }
  .doc-sec > h2, .doc h2.sec-title { break-after: avoid; }
  .page-break { break-before: page; }
}
