:root {
  --brand: #2e9a88;
  --brand-2: #38a870;
  --deep: #1c6b73;
  --ink: #12313a;
  --muted: #5b7078;
  --line: #dbe6e4;
  --bg: #f2f6f5;
  --card: #ffffff;
  --soft: #e8f4f1;
  --ok: #1d9a5f;
  --ok-soft: #e2f5ea;
  --warn: #b7791f;
  --warn-soft: #fbf1df;
  --danger: #c0392b;
  --wa: #1fae55;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(18, 49, 58, .06), 0 6px 20px rgba(18, 49, 58, .06);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, sans-serif;
  background: var(--bg); color: var(--ink); line-height: 1.7; font-size: 15px;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--deep); }

/* ===== الهوية: الشريط العلوي ===== */
.topbar { background: #fff; border-bottom: 1px solid var(--line); }
.topbar .in { max-width: 1180px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 14px; }
.topbar img.moe { height: 46px; }
.topbar img.oasis { height: 46px; margin-inline-start: auto; }
.topbar .t { border-inline-start: 1px solid var(--line); padding-inline-start: 14px; line-height: 1.4; }
.topbar .t b { display: block; font-size: 15px; }
.topbar .t span { color: var(--muted); font-size: 12.5px; }
.band { height: 4px; background: linear-gradient(90deg, var(--brand-2), var(--brand), var(--deep)); }

.hero { background: linear-gradient(135deg, var(--deep), var(--brand) 70%, var(--brand-2)); color: #fff; }
.hero .in { max-width: 1180px; margin: 0 auto; padding: 26px 16px 30px; }
.hero h1 { margin: 0 0 4px; font-size: 22px; font-weight: 700; }
.hero p { margin: 0; opacity: .9; font-size: 14px; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 20px 16px 60px; }
.narrow { max-width: 760px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px; }
.card h2 { margin: 0 0 14px; font-size: 16.5px; display: flex; align-items: center; gap: 10px; }
.card h2 .num { width: 26px; height: 26px; border-radius: 50%; background: var(--soft); color: var(--deep); display: grid; place-items: center; font-size: 13px; flex: none; }

/* ===== النماذج ===== */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; font-weight: 500; }
.field label .req { color: var(--danger); }
.field input[type=text], .field input[type=tel], .field textarea, .field select, .input {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fff; outline: none; transition: border .15s, box-shadow .15s;
}
.field input:focus, .field textarea:focus, .input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(46, 154, 136, .15); }
.field input[readonly] { background: #f7faf9; color: var(--muted); }
.field .err { color: var(--danger); font-size: 12.5px; min-height: 1em; margin-top: 3px; }
.field.bad input { border-color: var(--danger); }
.ltr { direction: ltr; text-align: right; unicode-bidi: plaintext; }
.span2 { grid-column: 1 / -1; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.chip span { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border: 1px solid var(--line); border-radius: 999px; background: #fff; font-size: 14px; }
.chip input:checked + span { background: var(--soft); border-color: var(--brand); color: var(--deep); font-weight: 600; }
.chip input:focus-visible + span { box-shadow: 0 0 0 3px rgba(46, 154, 136, .25); }

.terms { margin: 0; padding-inline-start: 22px; }
.terms li { margin-bottom: 8px; }
.lead { font-weight: 600; margin: 0 0 10px; }

.check { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; cursor: pointer; background: #fff; }
.check:has(input:checked) { border-color: var(--brand); background: var(--soft); }
.check input { width: 20px; height: 20px; margin-top: 3px; accent-color: var(--brand); flex: none; }

/* لوحة التوقيع */
.sigpad { position: relative; border: 1.5px dashed #a9c4c0; border-radius: 12px; background: #fff; height: 200px; touch-action: none; }
.sigpad canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; border-radius: 12px; }
.sigpad .base { position: absolute; left: 24px; right: 24px; bottom: 46px; border-bottom: 1px solid #d5e2e0; pointer-events: none; }
.sigpad .ph { position: absolute; inset: 0; display: grid; place-items: center; color: #9db3af; pointer-events: none; font-size: 15px; }
.sigpad.has .ph { display: none; }
.sig-tools { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; font-size: 13px; color: var(--muted); }

/* أزرار */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 9px 16px; cursor: pointer; font-weight: 600; font-size: 14px; text-decoration: none; color: var(--ink); white-space: nowrap; }
.btn:hover { border-color: #b9cfcb; background: #f7fbfa; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--deep); }
.btn.wa { background: var(--wa); border-color: var(--wa); color: #fff; }
.btn.wa:hover { filter: brightness(.95); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn.lg { padding: 13px 22px; font-size: 16px; width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn svg { width: 17px; height: 17px; flex: none; }

.notice { border-radius: 12px; padding: 12px 14px; font-size: 14px; display: flex; gap: 10px; align-items: flex-start; }
.notice.info { background: var(--soft); color: var(--deep); }
.notice.warn { background: var(--warn-soft); color: #7a5212; }
.notice.ok { background: var(--ok-soft); color: #135c39; }

.done-box { text-align: center; padding: 34px 20px; }
.done-box .ic { width: 72px; height: 72px; border-radius: 50%; background: var(--ok-soft); color: var(--ok); display: grid; place-items: center; margin: 0 auto 12px; }
.done-box .ic svg { width: 38px; height: 38px; }
.done-box h2 { justify-content: center; font-size: 20px; }

/* ===== لوحة المتابعة ===== */
.kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 16px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.kpi .l { color: var(--muted); font-size: 13px; }
.kpi .v { font-size: 30px; font-weight: 700; line-height: 1.3; font-variant-numeric: tabular-nums; }
.kpi .s { font-size: 12.5px; color: var(--muted); }
.kpi.ok .v { color: var(--ok); }
.kpi.warn .v { color: var(--warn); }
.kpi.pct { background: linear-gradient(135deg, var(--deep), var(--brand)); color: #fff; border: 0; }
.kpi.pct .l, .kpi.pct .s { color: rgba(255,255,255,.85); }
.bar { height: 8px; background: #e6eeec; border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--ok); border-radius: 99px; transition: width .4s; }
.kpi.pct .bar { background: rgba(255,255,255,.25); margin-top: 6px; }
.kpi.pct .bar i { background: #fff; }

.types { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.types .row { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 6px; }
.types .row b { font-variant-numeric: tabular-nums; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar .search { flex: 1 1 240px; }
.seg { display: inline-flex; background: #e9f0ef; border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; cursor: pointer; font-size: 13.5px; color: var(--muted); font-weight: 600; }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }

table.list { width: 100%; border-collapse: collapse; font-size: 14px; }
table.list th { text-align: right; font-size: 12.5px; color: var(--muted); font-weight: 600; padding: 10px; border-bottom: 1px solid var(--line); background: #f8fbfa; position: sticky; top: 0; }
table.list td { padding: 10px; border-bottom: 1px solid #edf2f1; vertical-align: top; }
table.list tr:hover td { background: #fafdfc; }
table.list .nm { font-weight: 600; }
table.list .sub { color: var(--muted); font-size: 12.5px; }
table.list .tt { max-width: 300px; }
.tbl-wrap { overflow: auto; max-height: 70vh; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: 99px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.pend { background: var(--warn-soft); color: var(--warn); }
.badge.type { background: #eef3f6; color: #46606b; font-weight: 500; }
.badge.grp { background: #eef0fb; color: #4b4fa3; font-weight: 500; }
.badge.rep { background: #fdf0f3; color: #a3364f; font-weight: 500; }
.badge.sent { background: #e7f7ee; color: #15803d; font-weight: 500; }
.row-act { display: flex; gap: 6px; flex-wrap: nowrap; }

/* نافذة منبثقة */
.modal { position: fixed; inset: 0; background: rgba(10, 30, 35, .5); display: none; align-items: flex-start; justify-content: center; padding: 30px 16px; z-index: 50; overflow: auto; }
.modal.open { display: flex; }
.modal .box { background: #fff; border-radius: 16px; width: 100%; max-width: 760px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal .mh { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal .mh h3 { margin: 0; font-size: 16px; }
.modal .mb { padding: 18px; }
.modal .mf { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.q-list { max-height: 46vh; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.q-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-bottom: 1px solid #eef3f2; }
.q-item:last-child { border-bottom: 0; }
.q-item .who { flex: 1; min-width: 0; }
.q-item .who b { display: block; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.q-item .who span { font-size: 12px; color: var(--muted); }
.q-item.sent { background: #f4fbf7; }
.preview-scale { background: #e9efee; border-radius: 12px; padding: 14px; overflow: auto; }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 10px; opacity: 0; transition: .25s; z-index: 80; font-size: 14px; pointer-events: none; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.demo-bar { background: var(--warn-soft); border-bottom: 1px solid #f0dcb4; color: #7a5212; font-size: 13.5px; }
.demo-bar .in { max-width: 1180px; margin: 0 auto; padding: 8px 16px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.demo-bar .in .sp { flex: 1; }

/* ===== ورقة الاتفاقية A4 ===== */
/* الصفحة ثابتة A4، والخط يصغر تلقائيًا (--fs) إذا زاد المحتوى حتى لا تتجاوز صفحة واحدة */
.sheet { --fs: 11pt; width: 210mm; height: 297mm; overflow: hidden; background: #fff; margin: 0 auto; padding: 10mm 13mm 17mm; color: #000; font-size: var(--fs); line-height: 1.65; position: relative; border: 1px solid #ccc; }
.sh-head { display: flex; align-items: center; justify-content: space-between; border-bottom: 1.5px solid #2e9a88; padding-bottom: 2mm; }
.sh-head img { height: 22mm; }
.sh-org { font-size: 9.5pt; color: #444; text-align: center; }
.sh-title { font-size: 1.22em; text-align: center; margin: 4.5mm 0 4mm; line-height: 1.5; }
.sh-grid, .sh-sign { width: 100%; border-collapse: collapse; }
.sh-grid th, .sh-grid td, .sh-sign th, .sh-sign td { border: 1px solid #333; padding: 1.2mm 2.2mm; text-align: right; font-size: .93em; }
.sh-grid th { background: #f1f6f5; width: 24mm; white-space: nowrap; font-weight: 700; }
.sh-types { display: flex; gap: 6mm; flex-wrap: wrap; }
.sh-box { display: inline-grid; place-items: center; width: 12px; height: 12px; border: 1.2px solid #222; font-size: 9px; line-height: 1; vertical-align: -2px; font-weight: 700; }
.sh-box.on { background: #e8f4f1; }
.sh-h { font-size: 1.1em; text-align: center; margin: 4.5mm 0 2mm; }
.sh-terms { margin: 0; padding-inline-start: 6mm; }
.sh-terms li { margin-bottom: 1mm; }
.sh-consent p { margin: 0 0 1.5mm; }
.sh-sign { margin-top: 5mm; }
.sh-sign th { text-align: center; background: #f1f6f5; width: 33.3%; }
.sh-sign td { text-align: center; height: 24mm; vertical-align: middle; }
.sh-sign td.sig img { max-height: 22mm; max-width: 100%; display: block; margin: 0 auto; }
.sh-foot { position: absolute; bottom: 7mm; left: 13mm; right: 13mm; font-size: 8pt; color: #777; text-align: center; border-top: 1px solid #ddd; padding-top: 1.5mm; }

#printArea { display: none; }

@media print {
  @page { size: A4; margin: 0; }
  body { background: #fff; }
  body.printing > *:not(#printArea) { display: none !important; }
  body.printing #printArea { display: block; }
  html, body { margin: 0 !important; padding: 0 !important; }
  .sheet { border: 0; margin: 0; page-break-after: always; break-after: page; page-break-inside: avoid; }
  .sheet:last-child { page-break-after: auto; break-after: auto; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 860px) {
  .kpis { grid-template-columns: 1fr 1fr; }
  .types { grid-template-columns: 1fr; gap: 12px; }
  table.list thead { display: none; }
  table.list, table.list tbody, table.list tr, table.list td { display: block; width: 100%; }
  table.list tr { border-bottom: 1px solid var(--line); padding: 8px 0; }
  table.list td { border: 0; padding: 3px 12px; }
  table.list .tt { max-width: none; }
  .tbl-wrap { max-height: none; }
}
@media (max-width: 600px) {
  .grid2 { grid-template-columns: 1fr; }
  .topbar .t { display: none; }
  .topbar img.moe, .topbar img.oasis { height: 38px; }
  .hero h1 { font-size: 18px; }
  .card { padding: 16px; }
  .kpi .v { font-size: 24px; }
}

/* ===== هيدر لوحة المتابعة بلون مختلف عن صفحة المشارك ===== */
.topbar.admin-head { background: linear-gradient(135deg, #0e3a44 0%, #165a64 55%, #1c6b73 100%); border-bottom: 0; }
.topbar.admin-head .in { padding-top: 14px; padding-bottom: 14px; }
.topbar.admin-head img { background: #fff; border-radius: 10px; padding: 4px 8px; height: 52px; box-shadow: 0 2px 8px rgba(0,0,0,.18); }
.topbar.admin-head .t { border-inline-start-color: rgba(255,255,255,.25); }
.topbar.admin-head .t b { color: #fff; font-size: 17px; }
.topbar.admin-head .t span { color: rgba(255,255,255,.78); }
.topbar.admin-head + .band { background: linear-gradient(90deg, #c9a24a, #e2c67a, #c9a24a); height: 3px; }
