/* حاسبة المواريث — بألوان وخطوط الموقع (متغيرات style.css). الأخضر = وارث، الرمادي + 🔒 = محجوب. */
.mw-page { padding-bottom: 50px; }
.mw-wizard { padding: 22px 24px; }
.hint { font-size: 0.84rem; color: var(--ink-soft); margin: 0 0 10px; line-height: 1.8; }

/* الخطوات */
.wiz-steps { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin: 0 0 22px; list-style: none; padding: 0; }
.wiz-steps button { width: 100%; display: flex; align-items: center; gap: 8px; padding: 9px 10px; border: 0; border-radius: var(--radius-md); background: var(--surface-soft); color: var(--ink-faint); font: inherit; font-weight: 600; font-size: 0.84rem; cursor: pointer; text-align: start; min-height: 44px; }
.wiz-steps button:disabled { cursor: default; }
.wiz-steps .n { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); font-family: var(--font-mono); font-size: 0.82rem; flex-shrink: 0; }
.wiz-steps li.active button { background: var(--brand); color: #fff; } .wiz-steps li.active .n { background: var(--gold-bright); color: var(--brand-deep); }
.wiz-steps li.done button { background: var(--brand-wash); color: var(--brand); } .wiz-steps li.done .n { background: var(--brand); color: #fff; }
@media (max-width: 720px) {
  .wiz-steps { gap: 4px; } .wiz-steps button { flex-direction: column; gap: 3px; padding: 7px 2px; text-align: center; font-size: 0.78rem; }
  .wiz-steps li:not(.active) .t { display: none; }
  .wiz-steps li.active { grid-column: span 1; }
}
.panel h2 { font-size: 1.2rem; color: var(--brand); margin: 0 0 4px; }
.panel .sub { color: var(--ink-soft); font-size: 0.9rem; margin: 0 0 18px; line-height: 1.9; }
.panel h3 { font-size: 1rem; margin: 0 0 6px; color: var(--ink); }
.panel h4 { font-size: 0.92rem; margin: 16px 0 8px; color: var(--ink); } .panel h4 small { color: var(--ink-faint); font-weight: 400; }

/* الخطوة 1: قوايم الأصول والديون والوصايا */
.mw-block { border: 1px solid var(--line); border-radius: var(--radius-md); padding: 14px 16px; margin-bottom: 14px; background: var(--surface); }
.mw-block-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.mw-cur { margin: 0; min-width: 160px; }
.mw-list { display: grid; gap: 8px; margin-bottom: 10px; }
.mw-item { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr) 40px; gap: 8px; align-items: center; }
.mw-item.two { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) 40px; }
.mw-item input, .mw-item select { width: 100%; }
.mw-item .rm { width: 40px; height: 40px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--cost); font-size: 1.1rem; cursor: pointer; }
.mw-item .tq { grid-column: 1 / -1; margin: -4px 0 0; }
@media (max-width: 640px) { .mw-item { grid-template-columns: 1fr 1fr 40px; } .mw-item > :first-child { grid-column: 1 / -1; } .mw-item.two { grid-template-columns: 1fr 40px; } .mw-item.two > :first-child { grid-column: 1 / -1; } }
.mw-settle { background: linear-gradient(160deg, var(--brand) 0%, var(--brand-deep) 100%); color: #fff; border-radius: var(--radius-lg); padding: 16px 20px; }
.mw-settle .warn { background: rgba(224,177,90,0.18); color: var(--gold-bright); border-radius: var(--radius-sm); padding: 8px 10px; margin-top: 8px; font-size: 0.86rem; }
.tq { font-size: 0.8rem; color: var(--brand-bright); font-weight: 600; min-height: 16px; margin: 4px 0 0; }
.chk { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-weight: 600; margin-top: 14px; line-height: 1.7; }
.chk input { width: 20px; height: 20px; accent-color: var(--brand); flex-shrink: 0; margin-top: 3px; }

.seg { display: inline-flex; background: var(--surface-soft); border-radius: var(--radius-sm); padding: 3px; gap: 3px; }
.seg label { cursor: pointer; } .seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: 10px 26px; border-radius: 4px; font-weight: 700; color: var(--ink-soft); }
.seg input:checked + span { background: var(--brand); color: #fff; } .seg input:focus-visible + span { outline: 2.5px solid var(--brand-bright); }

/* خانات الورثة مع الحالة الذكية */
.hgroup { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius-md); padding: 12px 16px 16px; margin: 0 0 14px; background: var(--surface); }
.hgroup legend { font-weight: 700; color: var(--brand); padding: 0 8px; font-family: var(--font-display); } .hgroup legend small { font-weight: 400; color: var(--ink-faint); font-family: var(--font-body); }
.opt-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(250px, 100%), 1fr)); }
.hf { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 6px 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--paper); transition: border-color .15s, background .15s; }
.hf.on { border-color: var(--gain); background: var(--gain-wash); }
.hf.locked { background: var(--surface-soft); }
.hf.locked.disabled { opacity: 0.62; }
.hf .tlabel { font-weight: 600; font-size: 0.92rem; }
.hf .st { grid-column: 1 / -1; font-size: 0.78rem; font-weight: 600; display: flex; gap: 5px; align-items: center; color: var(--ink-faint); min-height: 18px; }
.hf .st.ok { color: var(--gain); } .hf .st.lock { color: var(--ink-soft); }
.hf input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--brand); }
.stepper { display: inline-flex; align-items: center; border: 1.5px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); overflow: hidden; }
.stepper button { width: 38px; height: 40px; border: none; background: var(--surface-soft); font-size: 1.2rem; font-weight: 700; color: var(--brand); cursor: pointer; }
.stepper button:hover { background: var(--brand-wash); } .stepper button:disabled { color: var(--ink-faint); cursor: not-allowed; }
.stepper input { width: 46px; height: 40px; border: none; border-radius: 0; text-align: center; padding: 0; font-family: var(--font-mono); font-size: 1rem; -moz-appearance: textfield; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.err { background: var(--cost-wash); color: var(--cost); padding: 12px 14px; border-radius: var(--radius-sm); font-weight: 600; font-size: 0.9rem; margin-top: 14px; }
.nav-row { display: flex; gap: 10px; justify-content: space-between; margin-top: 20px; flex-wrap: wrap; }
.nav-row .btn { min-width: 130px; }

/* النتيجة */
.mw-res-top { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 14px; align-items: stretch; }
@media (max-width: 820px) { .mw-res-top { grid-template-columns: 1fr; } }
.sum { background: linear-gradient(160deg, var(--brand) 0%, var(--brand-deep) 100%); color: #fff; border-radius: var(--radius-lg); padding: 18px 20px; }
.sline { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 2px 12px; padding: 5px 0; font-size: 0.92rem; }
.sline span { flex: 1 1 150px; } .sline b { font-family: var(--font-mono); text-align: end; overflow-wrap: anywhere; }
.sline.net { border-top: 1px solid rgba(255,255,255,0.25); margin-top: 6px; padding-top: 10px; font-size: 1.05rem; color: var(--gold-bright); }
.mw-donut-wrap { display: flex; align-items: center; gap: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 14px; }
#donut svg { width: 170px; height: 170px; display: block; }
.mw-legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 0.84rem; flex: 1; min-width: 0; }
.mw-legend li { display: grid; grid-template-columns: 12px 1fr auto; gap: 8px; align-items: center; }
.mw-legend i { width: 12px; height: 12px; border-radius: 3px; }
.mw-legend b { font-family: var(--font-mono); direction: ltr; }
@media (max-width: 480px) { .mw-donut-wrap { flex-direction: column; } }
.mw-badges { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 0; }
.mw-badge { display: inline-flex; gap: 6px; align-items: center; padding: 6px 12px; border-radius: 999px; background: var(--gold-wash); color: #7A5310; font-weight: 700; font-size: 0.84rem; border: 0; font-family: inherit; cursor: pointer; }
.mw-badge.plain { background: var(--brand-wash); color: var(--brand); }
.mw-sec { margin-top: 26px; }
.mw-sec-head { display: flex; justify-content: space-between; align-items: baseline; gap: 6px 16px; flex-wrap: wrap; margin-bottom: 10px; }
.mw-sec-head h3 { margin: 0; font-size: 1.08rem; color: var(--brand); } .mw-sec-head .hint { margin: 0; }
.mw-masala { margin: 0; font-size: 0.9rem; color: var(--ink-soft); }
.mw-masala b { color: var(--brand); font-family: var(--font-mono); }

/* شجرة العيلة */
.ftree { display: grid; gap: 10px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 16px; position: relative; }
.ft-row { display: grid; grid-template-columns: 110px 1fr; gap: 10px; align-items: center; position: relative; }
.ft-row + .ft-row::before { content: ""; position: absolute; top: -10px; inset-inline-start: 50%; width: 2px; height: 10px; background: var(--line-strong); }
.ft-lbl { font-size: 0.78rem; font-weight: 700; color: var(--ink-faint); text-align: center; }
.ft-nodes { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.ft-me { background: var(--brand); color: #fff; border-radius: var(--radius-md); padding: 10px 18px; font-weight: 800; text-align: center; box-shadow: var(--shadow-sm); }
.ft-me small { display: block; font-weight: 500; opacity: .8; font-size: 0.78rem; }
.fn { position: relative; min-width: 128px; max-width: 190px; padding: 9px 11px 8px; border-radius: var(--radius-md); border: 1.5px solid var(--gain); background: var(--gain-wash); cursor: pointer; text-align: center; transition: transform .15s ease, box-shadow .15s ease; }
.fn:hover, .fn:focus-visible { transform: translateY(-2px); box-shadow: var(--shadow-md); outline: none; }
.fn .nm { display: block; font-weight: 700; font-size: 0.86rem; color: var(--ink); line-height: 1.4; }
.fn .ct { font-family: var(--font-mono); font-size: 0.78rem; color: var(--ink-soft); }
.fn .sh { display: block; font-family: var(--font-mono); font-weight: 700; color: var(--gain); margin-top: 3px; direction: ltr; }
.fn .am { display: block; font-family: var(--font-mono); font-size: 0.8rem; color: var(--ink); direction: ltr; }
.fn.blocked, .fn.zero { border-color: var(--line-strong); background: var(--surface-soft); border-style: dashed; }
.fn.blocked .nm, .fn.zero .nm { color: var(--ink-soft); } .fn.blocked .sh, .fn.zero .sh { color: var(--ink-faint); }
.fn .lock { position: absolute; top: -9px; inset-inline-end: -7px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 50%; width: 24px; height: 24px; display: grid; place-items: center; font-size: 0.72rem; }
.fn .ctl { display: flex; justify-content: center; gap: 6px; margin-top: 6px; }
.fn .ctl button { width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--line-strong); background: var(--surface); font-weight: 800; color: var(--brand); cursor: pointer; line-height: 1; }
.fn .tip { position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%); width: max-content; max-width: 230px; background: var(--ink); color: #fff; font-size: 0.8rem; line-height: 1.6; padding: 7px 10px; border-radius: var(--radius-sm); opacity: 0; pointer-events: none; transition: opacity .12s; z-index: 5; }
.fn:hover .tip, .fn:focus-visible .tip { opacity: 1; }
.fn.flash { animation: fn-flash .6s ease; }
@keyframes fn-flash { 0% { box-shadow: 0 0 0 0 rgba(20,128,63,.45); } 100% { box-shadow: 0 0 0 10px rgba(20,128,63,0); } }
@media (prefers-reduced-motion: reduce) { .fn, .fn.flash { transition: none; animation: none; } }
@media (max-width: 640px) {
  .ft-row { grid-template-columns: 1fr; } .ft-lbl { text-align: start; }
  .ft-row + .ft-row::before { display: none; }
  .fn { min-width: 0; flex: 1 1 140px; }
}
.mw-add { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; align-items: center; font-size: 0.84rem; color: var(--ink-faint); }
.mw-add button { border: 1px dashed var(--line-strong); background: var(--surface); border-radius: 999px; padding: 5px 11px; font: inherit; font-size: 0.82rem; color: var(--ink-soft); cursor: pointer; min-height: 32px; }
.mw-add button:hover { border-color: var(--brand); color: var(--brand); }

/* جدول النتيجة */
.rtable { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.rtable th { background: var(--surface-soft); padding: 10px 12px; text-align: start; font-size: 0.8rem; color: var(--ink-soft); }
.rtable td { padding: 11px 12px; border-top: 1px solid var(--line); vertical-align: top; }
.rtable td small { display: block; color: var(--ink-faint); font-size: 0.78rem; }
.rtable td.amt b { font-family: var(--font-mono); color: var(--brand); }
.rtable tr.muted td { color: var(--ink-faint); background: rgba(11,27,46,0.02); }
.rtable .acts { display: flex; gap: 6px; flex-wrap: wrap; }
.rtable .acts button { border: 1px solid var(--line-strong); background: var(--surface); border-radius: 999px; padding: 4px 10px; font: inherit; font-size: 0.78rem; cursor: pointer; color: var(--brand); min-height: 30px; }
.rtable .acts button.on { background: var(--gold-wash); border-color: var(--gold); color: #7A5310; }
.fr { font-family: var(--font-mono); font-weight: 600; unicode-bidi: isolate; direction: ltr; }
@media (max-width: 760px) {
  .rtable:not(.rpt-table) thead { display: none; }
  .rtable:not(.rpt-table), .rtable:not(.rpt-table) tbody, .rtable:not(.rpt-table) tr, .rtable:not(.rpt-table) td { display: block; width: 100%; }
  .rtable:not(.rpt-table) tr { border: 1px solid var(--line); border-radius: var(--radius-md); margin-bottom: 10px; padding: 6px 12px; background: var(--surface); }
  .rtable:not(.rpt-table) td { border: none; padding: 6px 0; display: flex; justify-content: space-between; gap: 14px; text-align: end; }
  .rtable:not(.rpt-table) td::before { content: attr(data-l); color: var(--ink-faint); font-size: 0.78rem; font-weight: 600; text-align: start; flex-shrink: 0; }
  .rtable:not(.rpt-table) td small { display: inline; margin-inline-start: 6px; }
}
.notes { margin: 18px 0 0; padding: 14px 16px 14px 20px; background: var(--gold-wash); border-radius: var(--radius-md); font-size: 0.88rem; line-height: 1.9; }
.notes ul { margin: 6px 0 0; padding-inline-start: 18px; }
.res-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.mw-asset { border: 1px solid var(--line); border-radius: var(--radius-md); padding: 12px 14px; margin-bottom: 10px; background: var(--surface); }
.mw-asset h4 { margin: 0 0 8px; }
.mw-tk-diff .up { color: var(--gain); font-weight: 700; } .mw-tk-diff .down { color: var(--cost); font-weight: 700; }

/* المصطلحات */
.gl { text-decoration: underline dotted var(--brand-bright); text-underline-offset: 4px; color: var(--brand-bright); cursor: help; font-weight: 600; }
.gl-pop { position: absolute; z-index: 90; max-width: 290px; background: var(--ink); color: #fff; padding: 10px 12px; border-radius: var(--radius-md); font-size: 0.84rem; line-height: 1.8; box-shadow: var(--shadow-lg); }
.gl-pop b { color: var(--gold-bright); display: block; margin-bottom: 2px; }

/* كروت الأدلة والتخارج */
.mw-dialog { border: 0; border-radius: var(--radius-lg); padding: 0; width: min(94vw, 580px); max-height: 88vh; box-shadow: var(--shadow-lg); color: var(--ink); }
.mw-dialog::backdrop { background: rgba(6, 27, 53, 0.55); }
.mw-dialog-body { padding: 22px; position: relative; overflow-y: auto; max-height: 86vh; }
.mw-dialog h3 { margin: 0 32px 10px 0; color: var(--brand); font-size: 1.1rem; }
.mw-x { position: absolute; top: 12px; inset-inline-end: 12px; width: 36px; height: 36px; border: 0; background: var(--surface-soft); border-radius: 50%; font-size: 1.3rem; cursor: pointer; }
.ev-share { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; background: var(--gain-wash); border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 12px; }
.ev-share b { font-family: var(--font-mono); font-size: 1.2rem; color: var(--gain); direction: ltr; }
.ev-share.blocked { background: var(--surface-soft); } .ev-share.blocked b { color: var(--ink-soft); }
.ev-card { border: 1px solid var(--line); border-inline-start: 4px solid var(--gold); border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 10px; }
.ev-card h4 { margin: 0 0 6px; font-size: 0.9rem; color: var(--ink-soft); }
.ev-card blockquote { margin: 0; font-family: 'Amiri', var(--font-display); font-size: 1.12rem; line-height: 2; color: var(--ink); }
.ev-card cite { display: block; font-style: normal; font-size: 0.8rem; color: var(--gold-ink); margin-top: 4px; font-weight: 700; }
.ev-card p { margin: 0; font-size: 0.88rem; line-height: 1.9; }

/* التقرير: مخفي على الشاشة، بيظهر في الطباعة وبيتصوّر لملف PDF */
#reportSheet { display: none; }
.rpt { font-family: 'Amiri', 'Traditional Arabic', 'Times New Roman', serif; color: #000; direction: rtl; line-height: 1.8; font-size: 15px; }
.rpt-capture { position: fixed; left: -10000px; top: 0; width: 794px; padding: 44px 50px; background: #fff; }
/* html2canvas بيفكّك الحروف العربي لو فيه letter-spacing (عناوين الموقع عليها 0.2px) */
.rpt, .rpt * { letter-spacing: 0 !important; }
.rpt h1, .rpt .rpt-title, .rpt h2 { font-family: inherit; color: #000; }
.rpt h1, .rpt .rpt-title { font-weight: 700; font-size: 24px; text-align: center; margin: 0 0 4px; } .rpt h2 { font-size: 17px; margin: 14px 0 6px; border-bottom: 1px solid #000; }
.rpt-b, .rpt-meta { text-align: center; margin: 0; font-size: 13px; } .rpt hr { border: 0; border-top: 1.5px solid #000; margin: 10px 0; }
.rpt .sline { padding: 2px 0; border-bottom: 1px dotted #999; font-size: 14px; color: #000; } .rpt .sline.net { border-top: 1.5px solid #000; color: #000; font-weight: 700; }
.rpt .sline b { font-family: inherit; }
.rpt .rtable { font-size: 13px; } .rpt .rtable th { background: #eee; color: #000; border: 1px solid #000; } .rpt .rtable td { border: 1px solid #000; color: #000; }
.rpt .rtable td small { color: #333; } .rpt .fr, .rpt .rtable td.amt b { font-family: inherit; color: #000; }
.rpt .rtable .acts { display: none; }
.rpt-tree { display: grid; gap: 6px; } .rpt-tree .row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.rpt-tree .row > span:first-child { width: 90px; font-weight: 700; font-size: 13px; }
.rpt-tree .n { border: 1px solid #000; border-radius: 6px; padding: 2px 8px; font-size: 13px; } .rpt-tree .n.x { border-style: dashed; color: #555; }
.rpt-flex { display: flex; gap: 20px; align-items: center; } .rpt-flex svg { width: 150px; height: 150px; flex-shrink: 0; }
.rpt-small { font-size: 12.5px; } .rpt-foot { text-align: center; font-size: 12px; margin-top: 14px; color: #444; }
@media print {
  .no-print, .breadcrumbs, .trust-badge, .hero { display: none !important; }
  #reportSheet { display: block !important; }
  body { background: #fff; } @page { size: A4; margin: 14mm; }
  .rpt tr, .rpt-tree .row { page-break-inside: avoid; }
}
/* الآية بالرسم العثماني والمرجع بعدها مباشرة، ودرجة الحديث */
.ev-card blockquote.ayah { font-family: 'Amiri', serif; font-size: 1.3rem; line-height: 2.3; }
.ev-card blockquote .ref { display: inline; font-family: var(--font-body); font-size: 0.82rem; color: var(--gold-ink); font-weight: 700; white-space: nowrap; }
.ev-card .grade { margin-top: 6px; font-size: 0.84rem; background: var(--brand-wash); border-radius: var(--radius-sm); padding: 6px 10px; }
.ev-card .grade b { color: var(--brand); }
.rpt li.ayah { font-size: 15px; }
/* الوصية الواجبة: فرع ابن/بنت متوفى (نوع الفرع + عدد الأولاد والبنات) */
.wb-group .hint { margin: 0 0 10px; }
.wb-list { display: grid; gap: 8px; margin-bottom: 10px; }
.mw-item.wb { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1fr) 40px; }
.wb-n { display: flex; align-items: center; gap: 6px; font-size: 0.82rem; color: var(--ink-soft); white-space: nowrap; }
.wb-n input { width: 100%; min-width: 0; }
@media (max-width: 640px) { .mw-item.wb { grid-template-columns: 1fr 1fr 40px; } .mw-item.wb > :first-child { grid-column: 1 / -1; } }
