/* =====================================================================
   صانع الشواهد — الأنماط
   ===================================================================== */
@font-face { font-family: 'EnjazMk'; font-weight: 400; font-display: block; src: url('fonts/Tajawal-Regular.woff2') format('woff2'), url('fonts/Tajawal-Regular.ttf') format('truetype'); }
@font-face { font-family: 'EnjazMk'; font-weight: 700; font-display: block; src: url('fonts/Tajawal-Bold.woff2') format('woff2'), url('fonts/Tajawal-Bold.ttf') format('truetype'); }
@font-face { font-family: 'EnjazMk'; font-weight: 800 900; font-display: block; src: url('fonts/Tajawal-ExtraBold.woff2') format('woff2'), url('fonts/Tajawal-ExtraBold.ttf') format('truetype'); }

/* زر «صناعة شاهد» بجانب «إرفاق صور أو PDF» */
.add-tile.maker-tile { border-style: solid; border-color: var(--gold); background: linear-gradient(160deg, #FFF9E6, #FFFDF6); color: #7A5E0C; cursor: pointer; font: inherit; }
.add-tile.maker-tile b { color: var(--gold); }
.add-tile.maker-tile:hover { background: #FFF3CF; }
html[data-ui="dark"] .add-tile.maker-tile { background: #2A2412; color: #F2CD55; }
.th-mk { position: absolute; top: 4px; left: 4px; background: var(--gold); color: #1d1605; font-size: 10px; font-weight: 800; padding: 1px 7px; border-radius: 6px; }
.th-tools .mk-edit { background: var(--gold); color: #1d1605; }

/* النافذة */
.mk-card { max-width: 1060px; }
.mk-h { font-size: 14px; margin: 14px 2px 8px; color: var(--prd); }
.mk-tpls { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.mk-tpl { text-align: start; display: flex; flex-direction: column; gap: 4px; padding: 14px; border: 1.5px solid var(--line); border-radius: 14px; background: var(--card); cursor: pointer; font: inherit; color: inherit; transition: .15s; }
.mk-tpl:hover { border-color: var(--gold); transform: translateY(-2px); box-shadow: var(--sh); }
.mk-tpl .i { font-size: 26px; } .mk-tpl b { font-size: 15px; } .mk-tpl small { color: var(--mut); font-size: 12.5px; line-height: 1.6; }
.mk-morebtn { margin-top: 12px; }
.mk-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.mk-top .m-title { margin: 0; }
.mk-auto { background: var(--prl); border: 1px solid #CFE6DC; color: var(--prd); border-radius: 12px; padding: 9px 12px; font-size: 13px; margin: 10px 0 12px; line-height: 1.8; }
.mk-auto em { color: #8A5A00; font-style: normal; font-weight: 700; }
html[data-ui="dark"] .mk-auto { background: #10261E; border-color: #24553D; color: #9FE0BE; }
.mk-split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 16px; align-items: start; }
.mk-form { display: flex; flex-direction: column; gap: 10px; max-height: 64vh; overflow-y: auto; padding-inline-end: 4px; }
.mk-form .fg { display: flex; flex-direction: column; gap: 5px; }
.mk-form .fg > span { font-weight: 700; font-size: 13.5px; }
.mk-form input, .mk-form textarea, .mk-form select { font: inherit; font-size: 14px; padding: 9px 11px; border: 1px solid var(--field-line); border-radius: 10px; background: var(--field); color: var(--ink); width: 100%; }
.mk-form textarea { resize: vertical; line-height: 1.7; }
.mk-gr { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.mk-gr label { display: flex; flex-direction: column; gap: 3px; text-align: center; } .mk-gr small { font-size: 11.5px; color: var(--mut); font-weight: 700; }
.mk-prev { position: sticky; top: 0; background: #E3EBE7; border-radius: 14px; padding: 10px; overflow: hidden; text-align: center; }
.mk-prev .mk-scale { transform-origin: top right; background: #fff; box-shadow: 0 6px 20px rgba(0,0,0,.12); text-align: start; }
.mk-prev small { display: block; margin-top: 4px; font-size: 11.5px; }
html[data-ui="dark"] .mk-prev { background: #0E1311; }
.mk-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
@media (max-width: 820px) {
  .mk-split { grid-template-columns: 1fr; }
  .mk-prev { position: static; order: -1; }
  .mk-form { max-height: none; }
  .mk-actions { position: sticky; bottom: -1px; background: var(--card); padding: 10px 0 2px; margin-top: 8px; }
  .mk-actions .btn { flex: 1; }
}
/* مسرح التحويل: خارج الشاشة ولا يؤثر على عرض الصفحة */
.mk-stage { position: fixed; top: 0; left: 0; width: 0; height: 0; overflow: hidden; z-index: -1; }

/* =====================================================================
   صفحة الشاهد A4 (794×1123) — تُرسم للمعاينة والتحويل
   ===================================================================== */
.mk-page { width: 794px; height: 1123px; box-sizing: border-box; padding: 34px 40px 30px; background: #fff; color: #16241F; direction: rtl; font-family: 'EnjazMk', 'Tajawal', 'Almarai', sans-serif; font-size: 14px; line-height: 1.75; display: flex; flex-direction: column; gap: 12px; overflow: hidden; position: relative; border-top: 10px solid var(--p); }
.mk-page::after { content: ''; position: absolute; inset: auto 0 0 0; height: 6px; background: linear-gradient(90deg, var(--p), var(--a)); }
.mk-page * { letter-spacing: 0 !important; }
.mk-head { display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid var(--line); padding-bottom: 10px; }
.mk-head small { display: block; color: #6E6556; font-size: 12px; font-weight: 700; }
.mk-head b { font-size: 17px; color: var(--pd); font-weight: 800; }
.mk-badge { width: 46px; height: 46px; border-radius: 14px; background: var(--p); display: flex; align-items: center; justify-content: center; font-size: 24px; box-shadow: inset 0 0 0 3px rgba(255,255,255,.25); }
.mk-title { margin: 2px 0 0; text-align: center; font-size: 30px; font-weight: 800; color: var(--pd); }
.mk-title::after { content: ''; display: block; width: 90px; height: 4px; border-radius: 3px; background: var(--a); margin: 6px auto 0; }
.mk-info { display: flex; flex-wrap: wrap; gap: 8px; }
.mk-info div { flex: 1 1 150px; background: #F6F9F7; border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; display: flex; flex-direction: column; }
.mk-info span { font-size: 11px; color: #6E6556; font-weight: 700; } .mk-info b { font-size: 14px; color: #16241F; }
.mk-box { border: 1.5px solid var(--line); border-radius: 12px; padding: 8px 14px 10px; background: #fff; }
.mk-box h3 { margin: 0 0 4px; font-size: 15px; color: var(--p); font-weight: 800; }
.mk-box ul, .mk-box ol { margin: 0; padding-inline-start: 20px; } .mk-box li { margin: 1px 0; } .mk-box p { margin: 0; }
.mk-box.inline ul { display: flex; flex-wrap: wrap; gap: 4px 22px; }
.mk-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mk-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.mk-steps .mk-box h3 { background: var(--p); color: #fff; margin: -8px -14px 8px; padding: 6px 12px; border-radius: 10px 10px 0 0; font-size: 14px; }
.mk-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.mk-kpis div { text-align: center; background: linear-gradient(160deg, var(--p), var(--pd)); color: #fff; border-radius: 12px; padding: 10px 6px; }
.mk-kpis b { display: block; font-size: 24px; font-weight: 800; line-height: 1.3; } .mk-kpis b small { font-size: 13px; opacity: .8; } .mk-kpis span { font-size: 12px; opacity: .9; }
.mk-chart { display: flex; align-items: flex-end; justify-content: space-around; gap: 10px; height: 215px; padding-top: 6px; border-bottom: 2px solid var(--line); }
.mk-bar { display: flex; flex-direction: column; align-items: center; gap: 3px; flex: 1; }
.mk-bar i { display: block; width: 58%; min-height: 3px; border-radius: 8px 8px 0 0; }
.mk-bar em { font-style: normal; font-weight: 800; font-size: 15px; } .mk-bar span { font-size: 12.5px; font-weight: 700; } .mk-bar small { font-size: 11px; color: #6E6556; }
.mk-rules { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mk-rules div { display: flex; align-items: center; gap: 8px; background: #F6F9F7; border-radius: 10px; padding: 7px 10px; font-weight: 700; }
.mk-rules b { width: 26px; height: 26px; border-radius: 50%; background: var(--a); color: #1d1605; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 13px; }
.mk-sign3 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.mk-sign3 div { border: 1.5px dashed var(--line); border-radius: 10px; padding: 8px 12px; min-height: 64px; display: flex; flex-direction: column; }
.mk-sign3 span { font-size: 12px; color: #6E6556; font-weight: 700; }
.mk-foot { margin-top: auto; display: flex; gap: 10px; border-top: 2px solid var(--line); padding-top: 10px; }
.mk-foot div { flex: 1; display: flex; flex-direction: column; } .mk-foot span { font-size: 11.5px; color: #6E6556; font-weight: 700; } .mk-foot b { font-size: 14px; }
.mk-page.mk-tight { gap: 8px; line-height: 1.6; } .mk-page.mk-tight .mk-box { padding: 6px 12px 8px; } .mk-page.mk-tight .mk-chart { height: 180px; }

.mk-fillbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; background: #FFF9E6; border: 1px solid #F1DDAE; border-radius: 12px; padding: 8px 12px; margin: -4px 0 12px; font-size: 13px; color: #6B5208; }
.mk-fillbar span { flex: 1; min-width: 180px; font-weight: 700; }
html[data-ui="dark"] .mk-fillbar { background: #2A2412; border-color: #54451F; color: #F2CD55; }

/* ---------- 4.15: صور داخل الشاهد، شعارات، ومعاينة ثابتة غير مقصوصة ---------- */
.mk-prev { overflow: visible; }
.mk-frame { position: relative; margin: 0 auto; overflow: hidden; border-radius: 6px; box-shadow: 0 6px 20px rgba(0,0,0,.14); background: #fff; }
.mk-frame .mk-scale { position: absolute; top: 0; right: 0; transform-origin: top right; box-shadow: none; }
.mk-phs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.mk-phs-i { position: relative; aspect-ratio: 1; border-radius: 10px; background: #eee center / cover; border: 1px solid var(--line); }
.mk-phs-i button { position: absolute; top: 4px; left: 4px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; font-size: 12px; cursor: pointer; }
.mk-phs-add { aspect-ratio: 1; border: 1.5px dashed var(--gold); border-radius: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: pointer; color: #7A5E0C; background: #FFFDF6; }
.mk-phs-add b { font-size: 22px; line-height: 1; } .mk-phs-add small { font-size: 11px; font-weight: 700; }
.mk-photos-fg > span small { color: var(--mut); font-weight: 500; }
/* داخل صفحة الشاهد */
.mk-logos { display: flex; align-items: center; gap: 8px; }
.mk-logo { height: 46px; width: auto; max-width: 90px; object-fit: contain; }
.mk-photos { display: grid; gap: 8px; }
.mk-photos.n1 { grid-template-columns: 1fr; } .mk-photos.n2 { grid-template-columns: 1fr 1fr; } .mk-photos.n3 { grid-template-columns: repeat(3, 1fr); } .mk-photos.n4 { grid-template-columns: repeat(4, 1fr); }
.mk-ph { height: 190px; border-radius: 10px; background: #f3f3f3 center / cover no-repeat; border: 3px solid #fff; box-shadow: 0 0 0 1.5px var(--line); }
.mk-photos.n1 .mk-ph { height: 240px; } .mk-photos.n4 .mk-ph { height: 150px; }
.mk-page.mk-ph-sm .mk-ph { height: 130px; } .mk-page.mk-ph-xs .mk-ph { height: 95px; }
