:root {
  --bg: #f3f4f6; --card: #ffffff; --text: #111827; --muted: #6b7280; --line: #e5e7eb; --line-2: #d1d5db;
  --primary: #0f5a3f; --primary-2: #0b4530; --primary-soft: #e6f2ec; --gold: #c9a24a;
  --danger: #b91c1c; --danger-soft: #fee2e2; --warn: #b45309; --warn-soft: #fef3c7;
  --ok: #15803d; --ok-soft: #dcfce7; --info: #1d4ed8; --info-soft: #dbeafe;
  --radius: 4px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: 'Alexandria', 'Segoe UI', Tahoma, Arial, sans-serif; font-size: 14px; line-height: 1.5; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h2 { font-size: 20px; margin: 0; font-weight: 600; }
#app { display: grid; grid-template-columns: 230px minmax(0, 1fr); grid-template-rows: auto 1fr; min-height: 100vh; }

/* الشريط الجانبي */
.sidebar { grid-row: 1 / span 2; background: linear-gradient(180deg, #021b14 0%, #082a1f 100%); color: #cfe0d7; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { background: #021b14; padding: 14px 18px 10px; border-bottom: 1px solid rgba(255,255,255,.08); text-align: center; }
.brand-logo { width: 100%; max-width: 170px; height: auto; display: block; margin: 0 auto; }
nav { flex: 1; padding: 10px 12px; overflow-y: auto; }
nav a { display: flex; align-items: center; gap: 10px; padding: 8px 12px; margin: 1px 0; border-radius: 6px; color: #cfe0d7; font-size: 13.5px; position: relative; }
nav a .ico { width: 18px; height: 18px; flex-shrink: 0; opacity: .8; }
nav a:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
nav a.active { background: rgba(255,255,255,.12); color: #fff; font-weight: 600; }
nav a.active .ico { opacity: 1; }
nav a.active::before { content: ''; position: absolute; inset-inline-start: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--gold); }
nav .nav-sep { font-size: 10.5px; color: #86a695; padding: 16px 12px 6px; font-weight: 600; letter-spacing: .04em; }
nav .nav-sep:first-child { padding-top: 4px; }
.sidebar-footer { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.08); }
.user-box { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--gold); color: #082a1f; font-weight: 700; font-size: 13px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.user-meta { min-width: 0; }
.user-meta b { display: block; color: #fff; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta span { color: #9dbcab; font-size: 11.5px; }
.icon-btn { background: transparent; border: 1px solid transparent; color: inherit; width: 34px; height: 34px; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; }
.icon-btn svg { width: 18px; height: 18px; }
.sidebar .icon-btn { color: #9dbcab; }
.sidebar .icon-btn:hover { background: rgba(255,255,255,.08); color: #fff; }
.topbar .icon-btn { color: var(--text); border-color: var(--line-2); }
.backdrop { display: none; position: fixed; inset: 0; background: rgba(17,24,39,.45); z-index: 30; }
.backdrop.show { display: block; }

.topbar { background: var(--card); border-bottom: 1px solid var(--line); padding: 10px 24px; display: flex; align-items: center; gap: 12px; font-weight: 600; font-size: 15px; }
#menu-btn { display: none; }
main { padding: 22px 24px; max-width: 1400px; width: 100%; min-width: 0; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }

/* بطاقات ولوحات */
.card, .panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; }
.card h3 { margin: 0 0 12px; font-size: 15px; font-weight: 600; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.panel { padding: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.panel-head h3 { margin: 0; font-size: 14px; font-weight: 600; }
.panel-head a { font-size: 13px; }
.panel .table-wrap { padding: 0; }
.panel .empty { padding: 20px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid > .card, .grid > .panel { margin-bottom: 0; }
.grid.grid-2 { margin-bottom: 16px; }

/* مؤشرات رئيسية */
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 16px; }
.kpi-row.kpi-3 { grid-template-columns: repeat(3, 1fr); }
.kpi { padding: 14px 18px; border-inline-end: 1px solid var(--line); }
.kpi:last-child { border-inline-end: 0; }
.kpi-label { color: var(--muted); font-size: 12px; }
.kpi-value { font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; direction: ltr; text-align: right; margin-top: 2px; }
.kpi-sub { color: var(--muted); font-size: 12px; }

/* بطاقات إحصائية (بقية الصفحات) */
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat .label { color: var(--muted); font-size: 12px; }
.stat .value { font-size: 20px; font-weight: 600; margin-top: 2px; }
.stat .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.stat.danger .value { color: var(--danger); } .stat.warn .value { color: var(--warn); }

/* الجداول */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 8px 12px; border-bottom: 1px solid var(--line); text-align: right; vertical-align: middle; }
th { background: #f9fafb; color: var(--muted); font-weight: 600; font-size: 12px; white-space: nowrap; }
tbody tr:hover td { background: #fafafa; }
tfoot td { font-weight: 600; background: #f9fafb; border-top: 1px solid var(--line-2); }
td.num, th.num { text-align: left; font-variant-numeric: tabular-nums; direction: ltr; white-space: nowrap; }
.table-wrap { overflow-x: auto; }
table.plain tbody tr:last-child td { border-bottom: 0; }
table.plain tfoot td { border-bottom: 0; }
.kv-table td { padding: 8px 16px; }
.kv-table td:first-child { color: var(--muted); }
.kv-table tr:last-child td { border-bottom: 0; }
.sheet th, .sheet td { padding: 6px 8px; white-space: nowrap; }
.sheet .m0 { color: #c4c8cf; }
.sheet .sticky { position: sticky; right: 0; background: #fff; z-index: 1; }
.sheet td.cell-pay { cursor: pointer; }
.sheet td.cell-pay:hover { background: var(--primary-soft); }

/* الأزرار */
.btn { border: 1px solid var(--primary); background: var(--primary); color: #fff; padding: 7px 14px; border-radius: var(--radius); cursor: pointer; font-family: inherit; font-size: 13.5px; font-weight: 500; line-height: 1.4; }
.btn:hover { background: var(--primary-2); text-decoration: none; }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-sm { padding: 4px 10px; font-size: 12.5px; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line-2); }
.btn-ghost:hover { background: #f3f4f6; }
.btn-danger { background: var(--danger); border-color: var(--danger); } .btn-danger:hover { background: #991b1b; }
.btn-outline { background: #fff; color: var(--primary); border-color: var(--primary); } .btn-outline:hover { background: var(--primary-soft); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* النماذج */
label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; font-weight: 500; }
input, select, textarea { width: 100%; padding: 7px 10px; border: 1px solid var(--line-2); border-radius: var(--radius); font-family: inherit; font-size: 13.5px; background: #fff; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
input[type=number] { direction: ltr; text-align: right; }
.field { margin-bottom: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 14px; }
.form-grid .full { grid-column: 1 / -1; }
.hint { font-size: 12px; color: var(--muted); }
.check { display: flex; align-items: center; gap: 8px; color: var(--text); }
.check input { width: auto; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 12px; }
.filters .field { margin: 0; min-width: 160px; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 3px; font-size: 12px; font-weight: 500; }
.badge-ok { background: var(--ok-soft); color: var(--ok); } .badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); } .badge-info { background: var(--info-soft); color: var(--info); }
.badge-muted { background: #f3f4f6; color: var(--muted); }
.money { font-variant-numeric: tabular-nums; direction: ltr; display: inline-block; }
/* خلية جدول تحمل .money تبقى خلية جدول (inline-block كان يكسر محاذاة الأعمدة) */
td.money, th.money { display: table-cell; }
.pos { color: var(--ok); } .neg { color: var(--danger); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.empty { text-align: center; color: var(--muted); padding: 28px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 13.5px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-weight: 500; }
.tree ul { list-style: none; padding-inline-start: 22px; margin: 4px 0; border-inline-start: 1px solid var(--line-2); }
.tree li { padding: 4px 0; }
.tree .node { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tree .node .btn { padding: 2px 8px; font-size: 12px; }
.voided td { text-decoration: line-through; color: var(--muted); background: #fff7f7; }
.alert { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 12px; font-size: 13.5px; border: 1px solid transparent; }
.alert-danger { background: var(--danger-soft); color: #991b1b; border-color: #fecaca; } .alert-warn { background: var(--warn-soft); color: #92400e; border-color: #fde68a; } .alert-ok { background: var(--ok-soft); color: #166534; border-color: #bbf7d0; }

/* النوافذ المنبثقة */
.modal-bg { position: fixed; inset: 0; background: rgba(17,24,39,.5); display: flex; align-items: flex-start; justify-content: center; padding: 40px 12px; z-index: 50; overflow-y: auto; }
.modal { background: #fff; border-radius: 6px; width: 100%; max-width: 640px; padding: 20px; box-shadow: 0 10px 40px rgba(0,0,0,.2); }
.modal.wide { max-width: 900px; }
.modal h3 { margin: 0 0 14px; font-size: 16px; font-weight: 600; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-start; margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.modal-err { color: var(--danger); font-size: 13px; margin-top: 8px; min-height: 18px; }
#toast-root { position: fixed; bottom: 20px; left: 20px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #1f2937; color: #fff; padding: 10px 16px; border-radius: var(--radius); animation: fade .2s; font-size: 13.5px; }
.toast.err { background: var(--danger); } .toast.ok { background: var(--ok); }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } }

/* تسجيل الدخول */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.login-card { background: #fff; padding: 32px; border: 1px solid var(--line); border-radius: 6px; width: 100%; max-width: 380px; }
.login-logo { display: block; width: 190px; margin: 0 auto 4px; }
.scope-bar { background: var(--primary-soft); border: 1px solid #cfe3d8; color: var(--primary); padding: 8px 14px; border-radius: var(--radius); margin-bottom: 14px; font-size: 13px; }
.login-card p { text-align: center; color: var(--muted); margin: 4px 0 20px; font-size: 13px; }

@media (max-width: 900px) {
  #app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; top: 0; bottom: 0; right: 0; left: auto; width: 260px; height: 100vh; transform: translateX(100%); transition: transform .2s; z-index: 40; box-shadow: -4px 0 20px rgba(0,0,0,.2); }
  .sidebar.open { transform: none; }
  #menu-btn { display: inline-block; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; }
  .kpi-row, .kpi-row.kpi-3 { grid-template-columns: 1fr 1fr; }
  .kpi:nth-child(2n) { border-inline-end: 0; } .kpi:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .form-grid { grid-template-columns: 1fr; }
  main { padding: 14px; }
}
@media (max-width: 560px) { .grid-2, .grid-3, .grid-4, .kpi-row, .kpi-row.kpi-3 { grid-template-columns: 1fr; } .kpi { border-inline-end: 0; border-bottom: 1px solid var(--line); } .kpi:last-child { border-bottom: 0; } }
@media print { .sidebar, .topbar, .btn, .filters { display: none !important; } #app { grid-template-columns: 1fr; } main { padding: 0; } .card, .panel { border: 0; } }

/* المستندات القابلة للطباعة (إيصالات وكشوفات) */
.doc { position: relative; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 26px; margin: 0 auto 16px; }
.doc-a5 { max-width: 560px; }
.doc-a4 { max-width: 1000px; }
.doc-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; border-bottom: 2px solid var(--gold); padding-bottom: 12px; margin-bottom: 12px; }
.doc-logo { width: 76px; height: auto; }
.doc-org b { font-size: 16px; color: var(--primary); }
.doc-no { text-align: center; font-size: 11.5px; color: var(--muted); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 14px; }
.doc-no b { display: block; font-size: 15px; color: var(--text); font-variant-numeric: tabular-nums; direction: ltr; }
.doc-title { text-align: center; font-size: 17px; font-weight: 700; color: var(--primary); margin: 4px 0 12px; }
.doc-kv { width: 100%; }
.doc-kv td { padding: 6px 10px; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.doc-kv tr:last-child td { border-bottom: 0; }
.doc-loanbox { background: #f9fafb; border: 1px solid var(--line); border-radius: var(--radius); margin-top: 10px; }
.doc-amount { display: flex; justify-content: space-between; align-items: center; gap: 14px; background: var(--primary-soft); border: 1px solid #cfe3d8; border-radius: var(--radius); padding: 10px 16px; margin: 12px 0 4px; }
.doc-amount .val { font-size: 24px; font-weight: 700; color: var(--primary); }
.doc-words { font-size: 13px; color: var(--primary); text-align: start; }
.doc-sign { display: flex; justify-content: space-between; gap: 30px; margin-top: 40px; }
.doc-sign div { text-align: center; width: 42%; border-top: 1px dashed var(--line-2); padding-top: 6px; color: var(--muted); font-size: 13px; }
.doc-foot { margin-top: 16px; font-size: 11px; color: var(--muted); text-align: center; border-top: 1px solid var(--line); padding-top: 8px; }
.void-stamp { display: inline-block; color: var(--danger); border: 2px solid var(--danger); border-radius: 4px; padding: 0 12px; font-size: 14px; transform: rotate(-6deg); margin-inline-start: 10px; }
@media print {
  body { background: #fff; }
  .no-print, #toast-root, .backdrop { display: none !important; }
  .doc { border: 0; border-radius: 0; padding: 0; margin: 0; max-width: none; }
  .doc-head { break-inside: avoid; }
  .doc tr { break-inside: avoid; }
}

/* مصفوفة الصلاحيات */
.perm-box { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin-top: 6px; }
.perm-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 18px; }
.perm-group { border-top: 1px solid var(--line); padding-top: 6px; }
.perm-group-title { font-weight: 600; color: var(--primary); font-size: 12.5px; margin-bottom: 4px; }
.perm-item { font-size: 12.5px; margin: 2px 0; }
@media (max-width: 700px) { .perm-grid { grid-template-columns: 1fr; } }
/* ملف المقترض */
.stepper { display: flex; gap: 0; margin: 0 0 14px; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.step { flex: 1; padding: 8px 12px; font-size: 12.5px; color: var(--muted); background: #fff; border-inline-end: 1px solid var(--line); }
.step:last-child { border-inline-end: 0; }
.step b { display: block; color: var(--text); font-size: 13px; }
.step.done { background: var(--ok-soft); } .step.done b { color: var(--ok); }
.step.current { background: var(--primary-soft); } .step.current b { color: var(--primary); }
.step.rejected { background: var(--danger-soft); } .step.rejected b { color: var(--danger); }
.att-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.att { border: 1px solid var(--line); border-radius: var(--radius); padding: 6px; text-align: center; font-size: 12px; }
.att img { width: 100%; height: 110px; object-fit: cover; border-radius: 3px; display: block; margin-bottom: 4px; }
.att .pdf { height: 110px; display: flex; align-items: center; justify-content: center; background: #f3f4f6; border-radius: 3px; margin-bottom: 4px; color: var(--muted); }
.opinion { border-inline-start: 3px solid var(--gold); padding: 4px 10px; margin: 6px 0; background: #fafaf7; }
/* طباعة ملف المقترض A4 */
.appdoc { max-width: 820px; margin: 0 auto; background: #fff; border: 1px solid var(--line); padding: 26px 34px; font-size: 13.5px; line-height: 1.8; }
.appdoc h2 { text-align: center; color: var(--primary); font-size: 19px; margin: 0 0 2px; }
.appdoc .sal { text-align: center; font-weight: 600; margin-bottom: 10px; }
.appdoc .meta { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 12px; margin: 10px 0; background: #fafaf7; }
.appdoc .request { background: var(--primary-soft); border: 1px solid #cfe3d8; border-radius: var(--radius); padding: 10px 14px; margin: 10px 0; font-size: 14px; }
.appdoc h3 { color: var(--primary); border-bottom: 2px solid var(--gold); font-size: 15px; padding-bottom: 3px; margin: 16px 0 8px; break-after: avoid; }
.appdoc .kv2 { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 22px; }
.appdoc .kv2 div { padding: 3px 0; border-bottom: 1px dotted var(--line); }
.appdoc .kv2 span { color: var(--muted); }
.appdoc .kv2 .full { grid-column: 1 / -1; }
.appdoc .narr { white-space: pre-wrap; background: #fafafa; border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px; }
.appdoc .decision { display: inline-block; padding: 3px 16px; border: 2px solid; border-radius: 4px; font-weight: 700; }
.appdoc .att-page { break-before: page; text-align: center; }
.appdoc .att-page img { max-width: 100%; max-height: 240mm; border: 1px solid var(--line); }
.appdoc .sign { display: flex; justify-content: space-between; margin-top: 26px; gap: 20px; }
.appdoc .sign div { text-align: center; width: 30%; border-top: 1px dashed var(--line-2); padding-top: 6px; color: var(--muted); font-size: 12.5px; }
.qr-box { text-align: center; }
.qr-box canvas, .qr-box img { width: 96px; height: 96px; }
.qr-box .serial { font-size: 11px; color: var(--muted); direction: ltr; font-variant-numeric: tabular-nums; }
#scan-video { width: 100%; max-width: 420px; border-radius: var(--radius); background: #000; display: block; margin: 0 auto; }
@media print { .appdoc { border: 0; padding: 0; max-width: none; } .page-break { break-before: page; } }

/* ===== الترويسة الرسمية ===== */
.lh { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 12px; border-bottom: 2px solid var(--gold); padding-bottom: 8px; margin-bottom: 12px; }
.lh-pre { font-size: 10.5px; line-height: 1.5; color: #374151; justify-self: start; min-width: 0; }
.lh-pre .lh-strong { color: var(--primary); font-weight: 700; font-size: 11.5px; }
.lh-mid { text-align: center; }
.lh-title { color: var(--primary); font-weight: 700; font-size: 17px; line-height: 1.3; }
.lh-no { font-size: 12px; color: var(--muted); margin-top: 2px; }
.lh-no b { color: var(--text); }
.lh-logo { justify-self: end; }
.lh-logo img { height: 66px; width: auto; display: block; }
.lh-compact { gap: 6px; padding-bottom: 4px; margin-bottom: 6px; border-bottom-width: 1.5px; }
.lh-compact .lh-pre { font-size: .78em; line-height: 1.35; }
.lh-compact .lh-pre .lh-strong { font-size: .86em; }
.lh-compact .lh-title { font-size: 1.25em; }
.lh-compact .lh-no { font-size: .9em; }
.lh-compact .lh-logo img { height: 11mm; }
.lh-mini { gap: 4px; padding-bottom: 3px; margin-bottom: 4px; border-bottom-width: 1px; }
.lh-mini .lh-pre { font-size: .8em; }
.lh-mini .lh-title { font-size: 1.15em; }
.lh-mini .lh-no { font-size: .85em; }
.lh-mini .lh-logo img { height: 8.5mm; }

/* ===== خيارات الطباعة ===== */
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--radius); overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 6px 14px; font-family: inherit; font-size: 13px; cursor: pointer; color: var(--text); border-inline-start: 1px solid var(--line); }
.seg button:first-child { border-inline-start: 0; }
.seg button.on { background: var(--primary); color: #fff; }
.print-opts .po-row, .print-opts-bar .po-row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.print-opts .po-row > label:first-child, .print-opts-bar .po-row > label:first-child:not(.check) { min-width: 120px; margin: 0; }
.po-grid { display: grid; grid-template-columns: auto 1fr; gap: 18px 28px; align-items: start; }
.po-grid > div > label { display: block; margin-bottom: 6px; }
.per-cards { display: flex; gap: 8px; flex-wrap: wrap; }
.per-card { display: flex; flex-direction: column; align-items: center; gap: 3px; width: 92px; padding: 8px 4px; border: 1.5px solid var(--line-2); border-radius: 6px; background: #fff; cursor: pointer; font-family: inherit; color: var(--muted); }
.per-card span { font-size: 12.5px; color: var(--text); font-weight: 600; }
.per-card small { font-size: 11px; }
.per-card.on { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
@media (max-width: 800px) { .po-grid { grid-template-columns: 1fr; } }

/* ===== أوراق الإيصالات ===== */
.sheets-wrap { width: 100%; overflow: hidden; }
.sheets { margin: 0 auto; width: max-content; }
.rsheet { display: grid; background: #fff; margin: 0 auto 8mm; box-shadow: 0 2px 10px rgba(0,0,0,.15); overflow: hidden; }
.rsheet .cell { overflow: hidden; position: relative; }
.rsheet.cut .cell { outline: 0.25mm dashed #9ca3af; outline-offset: -0.15mm; }
.rcpt { font-size: var(--rfs, 9pt); line-height: 1.45; color: #111827; height: 100%; display: flex; flex-direction: column; position: relative; }
.rcpt .lh { gap: 2.5mm; }
.rcpt .lh-pre { font-size: .7em; line-height: 1.4; }
.rcpt .lh-pre .lh-strong { font-size: 1.07em; }
.rcpt.rcpt-compact .lh-title { font-size: 1.08em; }
.rcpt.rcpt-compact .lh-pre { font-size: .62em; }
.rcpt.rcpt-mini .lh-title { font-size: 1.05em; }
.rcpt.rcpt-mini .lh-pre { font-size: .7em; }
.rcpt .lh-title { font-size: 1.22em; }
.rcpt .lh-no { font-size: .92em; }
.rcpt-full .lh-logo img { height: 15mm; }
.r-title { text-align: center; font-weight: 700; color: var(--primary); font-size: 1.22em; margin: .1em 0 .45em; }
.r-kv { width: 100%; border-collapse: collapse; }
.r-kv td { padding: .28em .5em; border-bottom: 1px solid #e5e7eb; font-size: 1em; vertical-align: top; }
.r-kv td:first-child { color: #6b7280; white-space: nowrap; width: 1%; }
.r-kv tr:last-child td { border-bottom: 0; }
.r-muted { color: #6b7280; font-size: .9em; }
.r-amount { display: flex; justify-content: space-between; align-items: center; gap: .8em; background: var(--primary-soft); border: 1px solid #cfe3d8; border-radius: 4px; padding: .45em .8em; margin: .55em 0 .35em; }
.r-amount-num span { display: block; font-size: .82em; color: #6b7280; }
.r-amount-num b { font-size: 1.9em; color: var(--primary); line-height: 1.1; }
.r-words { font-size: .95em; color: var(--primary); text-align: start; }
.r-bal { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid #e5e7eb; border-radius: 4px; background: #f9fafb; }
.r-bal div { padding: .35em .6em; border-inline-start: 1px solid #e5e7eb; }
.r-bal div:first-child { border-inline-start: 0; }
.r-bal span { display: block; font-size: .8em; color: #6b7280; }
.r-balline { font-size: .9em; color: #374151; text-align: center; background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 3px; padding: .2em .4em; }
.r-bottom { display: flex; justify-content: space-between; align-items: flex-end; gap: 1em; margin-top: auto; padding-top: .6em; }
.r-signs { display: flex; gap: 1.2em; flex: 1; }
.r-signs div { flex: 1; max-width: 48mm; text-align: center; border-top: 1px dashed #9ca3af; padding-top: .25em; color: #6b7280; font-size: .9em; margin-top: 2.2em; }
.r-qr { text-align: center; }
.r-qr svg { width: 20mm; height: 20mm; display: block; }
.r-serial { font-size: .72em; color: #6b7280; direction: ltr; letter-spacing: .02em; }
.r-foot { font-size: .72em; color: #9ca3af; text-align: center; border-top: 1px solid #e5e7eb; margin-top: .5em; padding-top: .3em; }
.r-copy { position: absolute; top: 0; inset-inline-start: 0; font-size: .75em; background: #f3f4f6; color: #374151; border: 1px solid #d1d5db; border-radius: 3px; padding: 0 .5em; z-index: 2; }
.r-void { position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%) rotate(-18deg); font-size: 3em; font-weight: 700; color: rgba(185,28,28,.28); border: .12em solid rgba(185,28,28,.28); border-radius: .15em; padding: 0 .4em; z-index: 3; pointer-events: none; }
.r-voidnote { color: #b91c1c; font-size: .85em; margin-top: .3em; }
.rcpt-compact .r-qr svg { width: 14mm; height: 14mm; }
.rcpt-compact .r-signs div { margin-top: 1.6em; }
.rcpt-compact .r-amount-num b { font-size: 1.6em; }
.rcpt-mini .r-qr svg { width: 11.5mm; height: 11.5mm; }
.rcpt-mini .r-signs div { margin-top: 1.2em; }
.rcpt-mini .r-amount { padding: .3em .6em; margin: .35em 0 .25em; }
.rcpt-mini .r-amount-num b { font-size: 1.45em; }
.rcpt-mini .r-kv td { padding: .16em .4em; }
.rcpt-mini .r-title { font-size: 1.1em; margin-bottom: .25em; }

@media print {
  html, body { background: #fff !important; }
  .sheets { zoom: 1 !important; width: auto; }
  .rsheet { box-shadow: none !important; margin: 0 !important; break-after: page; }
  .rsheet:last-child { break-after: auto; }
  .print-opts-bar { display: none !important; }
}

/* ===== خانات الصور ===== */
.imgfield .thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.thumb { position: relative; width: 96px; height: 96px; border: 1px solid var(--line-2); border-radius: 5px; overflow: hidden; background: #f9fafb; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-x { position: absolute; top: 3px; inset-inline-end: 3px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: rgba(17,24,39,.75); color: #fff; cursor: pointer; font-size: 15px; line-height: 20px; padding: 0; }
.thumb-tag { position: absolute; bottom: 3px; inset-inline-start: 3px; background: var(--gold); color: #fff; font-size: 10px; padding: 0 5px; border-radius: 3px; }
.thumb.pending { border-color: var(--gold); border-style: dashed; }
.thumb-add { display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: pointer; color: var(--primary); border-style: dashed; }
.thumb-add b { font-size: 26px; line-height: 1; } .thumb-add small { font-size: 11px; }
.thumb-add:hover { background: var(--primary-soft); }
.extra-fields { margin: 10px 0; }
.extra-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.extra-row .cf-label { flex: 1.2; min-width: 180px; } .extra-row .cf-value { flex: 2; min-width: 180px; } .extra-row .cf-type { width: 90px; }
.appdoc .pimgs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 4px; }
.appdoc .pimgs img { width: 100%; height: 48mm; object-fit: cover; border: 1px solid var(--line); border-radius: 3px; break-inside: avoid; }

/* ===== توصيات الإدارة ===== */
.rec { display: inline-block; padding: 1px 10px; border-radius: 3px; font-size: 12px; font-weight: 600; border: 1px solid; white-space: nowrap; }
.rec-strong { color: #14532d; background: #dcfce7; border-color: #86efac; }
.rec-ok { color: #15803d; background: #f0fdf4; border-color: #bbf7d0; }
.rec-caution { color: #92400e; background: #fffbeb; border-color: #fde68a; }
.rec-cond { color: #9a3412; background: #fff7ed; border-color: #fdba74; }
.rec-no { color: #b91c1c; background: #fef2f2; border-color: #fecaca; }
.rec-ban { color: #fff; background: #991b1b; border-color: #991b1b; }

/* ===== تقرير الأهلية ===== */
.elig .elig-score { display: flex; gap: 22px; align-items: center; margin: 6px 0 8px; }
.gauge { width: 130px; height: 130px; flex-shrink: 0; }
.elig-kpis { flex: 1; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.elig-kpis div { border: 1px solid var(--line); border-radius: 4px; padding: 6px 10px; background: #fafaf7; }
.elig-kpis span { display: block; font-size: 11.5px; color: var(--muted); }
.elig-kpis b { font-size: 17px; }
.pos { color: var(--ok); } .warn-t { color: #b45309; } .info-t { color: #1d4ed8; }
.elig-loan { border: 1px solid var(--line); border-radius: 5px; padding: 10px 14px; margin: 10px 0; break-inside: avoid; }
.elig-loan h4 { margin: 0 0 2px; font-size: 14px; color: var(--primary); }
.elig-table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 12.5px; }
.elig-table th, .elig-table td { border: 1px solid var(--line); padding: 4px 8px; }
.elig-table th { background: #f3f4f6; }
.elig-clean { margin-top: 8px; color: var(--ok); font-size: 13px; }
.mstrip { display: flex; flex-wrap: wrap; gap: 3px; margin: 8px 0 2px; }
.ms { display: inline-block; width: 15px; height: 15px; border-radius: 3px; background: #e5e7eb; }
.ms-paid { background: #15803d; } .ms-allowed { background: #2563eb; } .ms-excused { background: #f59e0b; }
.ms-unexcused { background: #f97316; } .ms-unexcused.ms-full { background: #b91c1c; } .ms-excused.ms-full { background: #d97706; }
.ms-company_allowed { background: #2563eb; } .ms-current { background: #fff; border: 2px solid #6b7280; } .ms-future { background: #eef0f2; } .ms-extra { background: #60a5fa; }
.ms-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 11.5px; color: var(--muted); margin: 6px 0; }
.ms-legend span { display: inline-flex; align-items: center; gap: 5px; } .ms-legend .ms { width: 12px; height: 12px; }
.elig-rec { border: 1px solid var(--line); border-radius: 5px; padding: 10px 14px; }
.elig-rec-head { margin-bottom: 8px; } .elig-rec-head .rec { font-size: 15px; padding: 3px 14px; }
.elig-ratings td:first-child { width: 40%; color: var(--muted); }
.stars { color: var(--gold); letter-spacing: 2px; font-size: 15px; } .stars .off { color: #d1d5db; }
.rec-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.rec-card { display: flex; flex-direction: column; gap: 4px; border: 1.5px solid var(--line-2); border-radius: 6px; padding: 8px 10px; cursor: pointer; margin: 0; }
.rec-card input { display: none; } .rec-card small { color: var(--muted); font-size: 11.5px; }
.rec-card:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.star-input button { border: 0; background: none; font-size: 24px; color: #d1d5db; cursor: pointer; padding: 0 2px; }
.star-input button.on { color: var(--gold); }
@media (max-width: 800px) { .elig-kpis { grid-template-columns: repeat(2, 1fr); } .rec-cards { grid-template-columns: 1fr; } .elig .elig-score { flex-direction: column; } }
@media print { .elig-loan details { display: none; } }

/* ===== تقرير المتبرعين ===== */
.donor .dintro { white-space: pre-wrap; background: #fafaf7; border-inline-start: 3px solid var(--gold); padding: 10px 14px; margin: 8px 0 4px; line-height: 1.9; }
.dtiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.dtile { border: 1px solid var(--line); border-radius: 5px; padding: 8px 10px; background: #fff; break-inside: avoid; }
.dtile span { display: block; font-size: 11.5px; color: var(--muted); }
.dtile b { display: block; font-size: 19px; color: var(--text); font-variant-numeric: tabular-nums; }
.dtile small { display: block; font-size: 11px; color: var(--muted); }
.dchart { margin: 6px 0 8px; break-inside: avoid; }
.dlegend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 12px; color: var(--text); margin-bottom: 6px; }
.dlegend span { display: inline-flex; align-items: center; gap: 6px; } .dlegend i { width: 12px; height: 12px; border-radius: 2px; display: inline-block; }
.dplot { position: relative; height: 190px; padding-inline-start: 64px; }
.dgrid { position: absolute; inset: 0 0 22px 0; z-index: 0; display: flex; flex-direction: column; justify-content: space-between; }
.dgrid div { border-top: 1px solid #eceef0; position: relative; height: 0; }
.dgrid span { position: absolute; right: 0; top: -8px; font-size: 10.5px; color: var(--muted); direction: ltr; }
.dcols { position: absolute; top: 0; bottom: 0; left: 0; right: 64px; display: flex; align-items: stretch; z-index: 1; }
.dgroup { flex: 1; display: flex; flex-direction: column; align-items: center; }
.dbars { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 2px; padding-bottom: 0; margin-bottom: 22px; }
.dbar { width: min(16px, 22%); border-radius: 4px 4px 0 0; min-height: 0; }
.dlabel { position: absolute; bottom: 0; left: 0; right: 0; text-align: center; font-size: 11px; color: var(--muted); }
.dgroup { position: relative; }
.hbars { display: flex; flex-direction: column; gap: 6px; }
.hbar-row { display: grid; grid-template-columns: 170px 1fr 230px; gap: 10px; align-items: center; font-size: 12.5px; }
.hbar-track { height: 14px; background: #f3f4f6; border-radius: 3px; overflow: hidden; }
.hbar { height: 100%; background: #1f8a5c; border-radius: 3px; }
.hbar-val { font-variant-numeric: tabular-nums; }
.pstack { display: flex; height: 26px; border-radius: 4px; overflow: hidden; gap: 2px; background: #fff; }
.pstack div { color: #fff; font-size: 11.5px; font-weight: 600; display: flex; align-items: center; justify-content: center; min-width: 2px; }
.dtable { font-size: 12px; } .dtable tfoot td { font-weight: 700; background: #f3f4f6; }
@media (max-width: 800px) { .dtiles { grid-template-columns: repeat(2, 1fr); } .hbar-row { grid-template-columns: 110px 1fr; } .hbar-val { grid-column: 1 / -1; } }
@media print { .donor h3 { break-after: avoid; } .dtable tr { break-inside: avoid; } }

/* ===== الإعدادات: الترويسة ومنطقة الخطر ===== */
.lh-preview { border: 1px solid var(--line); border-radius: 5px; padding: 14px; background: #fff; }
.lh-preview .lh { margin: 0; }
.danger-zone { border-color: #fecaca; }
.danger-zone h3:first-child { color: var(--danger); }
.wsteps { display: flex; gap: 6px; margin-bottom: 12px; font-size: 12.5px; }
.wsteps span { flex: 1; padding: 6px 8px; border-radius: 4px; background: #f3f4f6; color: var(--muted); text-align: center; }
.wsteps span.cur { background: var(--danger-soft); color: var(--danger); font-weight: 600; }
.wsteps span.done { background: var(--ok-soft); color: var(--ok); }
.captcha-row { display: flex; align-items: center; gap: 10px; margin: 6px 0 10px; }
.captcha-row img { border: 1px solid var(--line-2); border-radius: 4px; }

/* ===== شريط الأعلى: الإشعارات والملاحظات ===== */
.topbar { position: sticky; top: 0; z-index: 25; }
.top-actions { margin-inline-start: auto; display: flex; align-items: center; gap: 6px; }
.top-btn { position: relative; width: 38px; height: 38px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--text); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.top-btn:hover { background: var(--primary-soft); color: var(--primary); text-decoration: none; }
.top-btn svg { width: 19px; height: 19px; }
.top-badge { position: absolute; top: -5px; inset-inline-end: -5px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; border: 2px solid #fff; }
.bell-wrap { position: relative; }
.bell-panel { position: absolute; top: 46px; inset-inline-end: 0; width: 400px; max-width: calc(100vw - 24px); background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 12px 40px rgba(0,0,0,.18); z-index: 60; font-weight: 400; font-size: 13.5px; }
.bp-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.bp-tasks { display: flex; flex-direction: column; gap: 4px; padding: 8px 12px; background: #fafaf7; border-bottom: 1px solid var(--line); }
.bp-task { font-size: 12.5px; color: var(--text); padding: 4px 8px; border-radius: 4px; background: #fff; border: 1px solid var(--line); }
.bp-task b { color: var(--primary); margin-inline-end: 4px; }
.bp-task.urgent { border-color: #fde68a; background: var(--warn-soft); }
.bp-list { max-height: 60vh; overflow-y: auto; }
.bp-foot { display: flex; justify-content: space-between; padding: 8px 12px; border-top: 1px solid var(--line); font-size: 12.5px; }
.nav-badge { margin-inline-start: auto; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
.btn .nav-badge { margin-inline-start: 6px; display: inline-block; }
.toast.warn { background: #92400e; }

/* صف إشعار */
.n-row { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer; position: relative; }
.n-row:hover { background: #f9fafb; }
.n-row.unread { background: #f3f9f6; }
.n-row.unread::before { content: ''; position: absolute; inset-inline-start: 0; top: 0; bottom: 0; width: 3px; background: var(--primary); }
.n-row.high.unread::before { background: var(--warn); }
.n-ico { width: 32px; height: 32px; border-radius: 50%; background: color-mix(in srgb, var(--c) 12%, #fff); color: var(--c); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.n-ico .ico { width: 17px; height: 17px; }
.n-main { flex: 1; min-width: 0; }
.n-title { font-weight: 500; }
.n-row.unread .n-title { font-weight: 700; }
.n-body { color: #374151; font-size: 12.5px; margin-top: 1px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.n-meta { color: var(--muted); font-size: 11.5px; margin-top: 3px; }
.n-acts { display: flex; gap: 2px; opacity: .55; }
.n-row:hover .n-acts { opacity: 1; }
.n-act { border: 0; background: transparent; cursor: pointer; width: 26px; height: 26px; border-radius: 4px; color: var(--muted); font-size: 13px; }
.n-act:hover { background: #e5e7eb; color: var(--text); }
.n-group { font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 4px 4px; }
.notif-grid { grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); align-items: start; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.tab { border: 0; background: transparent; padding: 8px 14px; font-family: inherit; font-size: 13.5px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab.on { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chip-btn { border: 1px solid var(--line-2); background: #fff; border-radius: 16px; padding: 3px 12px; font-family: inherit; font-size: 12.5px; cursor: pointer; }
.chip-btn.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.chip-btn.on .muted { color: #d1fae5; }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }

/* مهامي */
.task-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.task { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; color: var(--text); background: #fff; }
.task b { font-size: 22px; color: var(--primary); min-width: 28px; text-align: center; }
.task.urgent { border-color: #fcd34d; background: #fffbeb; }
.task.urgent b { color: var(--warn); }
.task:hover { text-decoration: none; border-color: var(--primary); }
.tasks-panel { margin-bottom: 16px; }

/* ===== الملاحظات والرسائل ===== */
.notes-layout { display: grid; grid-template-columns: 230px minmax(0, 1fr) minmax(0, 1.25fr); gap: 14px; align-items: start; }
.notes-layout > .card { margin-bottom: 0; }
.notes-side .field { margin-bottom: 8px; }
.boxes { display: flex; flex-direction: column; gap: 2px; margin-bottom: 10px; }
.box { display: flex; align-items: center; border: 0; background: transparent; padding: 7px 10px; border-radius: 6px; font-family: inherit; font-size: 13.5px; cursor: pointer; text-align: start; color: var(--text); }
.box:hover { background: #f3f4f6; }
.box.on { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.notes-list { padding: 0; max-height: calc(100vh - 170px); overflow-y: auto; }
.note-item { padding: 11px 14px; border-bottom: 1px solid var(--line); cursor: pointer; position: relative; }
.note-item:hover { background: #f9fafb; }
.note-item.on { background: var(--primary-soft); }
.note-item.unread::before { content: ''; position: absolute; inset-inline-start: 5px; top: 17px; width: 7px; height: 7px; border-radius: 50%; background: var(--primary); }
.note-item.unread .ni-subj { font-weight: 700; }
.ni-top { display: flex; gap: 6px; align-items: baseline; }
.ni-subj { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.ni-time { white-space: nowrap; }
.ni-snip { color: #4b5563; font-size: 12.5px; margin: 2px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ni-meta { font-size: 11.5px; color: var(--muted); }
.ni-chips { margin-top: 4px; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.tchip { display: inline-block; font-size: 11.5px; padding: 0 7px; border-radius: 10px; background: #f3f4f6; color: #374151; border: 1px solid var(--line); }
.tchip.pub { background: var(--info-soft); color: var(--info); border-color: #bfdbfe; }
.tchip.due { background: var(--danger-soft); color: var(--danger); border-color: #fecaca; }
.echip { display: inline-block; font-size: 11.5px; padding: 0 7px; border-radius: 10px; background: var(--primary-soft); border: 1px solid #cfe3d8; }
.notes-thread { max-height: calc(100vh - 170px); overflow-y: auto; }
.th-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.th-back { display: none; }
.msg { border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; margin: 10px 0; background: #fff; max-width: 92%; }
.msg.mine { background: #f3f9f6; border-color: #cfe3d8; margin-inline-start: auto; }
.msg-head { display: flex; gap: 8px; align-items: center; margin-bottom: 3px; }
.msg-head .n-act { margin-inline-start: auto; }
.msg-body { white-space: pre-wrap; line-height: 1.7; }
.reply-box { display: flex; gap: 8px; align-items: flex-end; margin-top: 10px; position: sticky; bottom: 0; background: #fff; padding-top: 6px; }
.reply-box textarea { flex: 1; }
.enotes { display: flex; flex-direction: column; gap: 6px; }
.enote { display: block; border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px; color: var(--text); position: relative; }
.enote:hover { border-color: var(--primary); text-decoration: none; }
.enote.unread { border-inline-start: 3px solid var(--primary); }
@media (max-width: 1100px) {
  .notes-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); }
  .notes-side { grid-column: 1 / -1; }
  .boxes { flex-direction: row; flex-wrap: wrap; }
}
@media (max-width: 760px) {
  .notes-layout { grid-template-columns: 1fr; }
  .notes-layout .notes-thread { display: none; }
  .notes-layout.has-open .notes-thread { display: block; }
  .notes-layout.has-open .notes-list, .notes-layout.has-open .notes-side { display: none; }
  .th-back { display: inline-block; }
  .notif-grid { grid-template-columns: 1fr; }
  .bell-panel { position: fixed; top: 56px; inset-inline: 8px; width: auto; }
}

/* اختيار المستخدمين والعناصر */
.upick { border: 1px solid var(--line-2); border-radius: var(--radius); padding: 6px; }
.upick-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; min-height: 22px; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--primary-soft); color: var(--primary); border: 1px solid #cfe3d8; border-radius: 14px; padding: 1px 4px 1px 10px; font-size: 12.5px; }
.chip button, .chip a { border: 0; background: transparent; cursor: pointer; color: inherit; font-size: 14px; padding: 0 4px; }
.upick-list { max-height: 150px; overflow-y: auto; margin-top: 6px; }
.upick-item { padding: 2px 4px; font-size: 13px; }
.epick { display: flex; gap: 8px; flex-wrap: wrap; }
.epick-type { width: 180px; }
.epick-search { flex: 1; min-width: 220px; position: relative; }
.epick-res { display: flex; flex-direction: column; max-height: 170px; overflow-y: auto; }
.epick-opt { border: 0; border-bottom: 1px solid var(--line); background: #fff; text-align: start; padding: 6px 8px; font-family: inherit; font-size: 13px; cursor: pointer; }
.epick-opt:hover, .epick-opt.on { background: var(--primary-soft); }

/* الرقم القومي */
.nid-msg { font-size: 12px; margin-top: 3px; min-height: 0; }
.nid-msg.err { color: var(--danger); font-weight: 600; }
.nid-msg.ok { color: var(--ok); }
.nid-msg.warn { color: var(--warn); }
input.invalid { border-color: var(--danger) !important; box-shadow: 0 0 0 3px var(--danger-soft) !important; }
input.autofilled { background: #f0fdf4; }

/* ===== ملفات المقترضين: المراحل الأربع ===== */
.kpi-row.kpi-6 { grid-template-columns: repeat(6, 1fr); }
.kpi-link { color: var(--text); }
.kpi-link:hover { background: var(--primary-soft); text-decoration: none; }
tr.row-await td { background: #fffbeb; }
.await-tag { color: var(--warn); font-weight: 600; }
.stepper.s5 .step { font-size: 12px; }
.inv-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.inv-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 5px 8px; border: 1px solid var(--line); border-radius: 5px; }
.inv-row .btn { margin-inline-start: auto; }
.inv-dot { width: 10px; height: 10px; border-radius: 50%; background: #d1d5db; flex-shrink: 0; }
.inv-dot.submitted { background: var(--ok); }
.inv-dot.draft { background: #f59e0b; }
.rec-sum { display: flex; gap: 12px; flex-wrap: wrap; margin: 6px 0 10px; font-size: 13px; }
.report-card { border: 1px solid var(--line); border-radius: 6px; padding: 9px 12px; margin: 8px 0; background: #fcfcfa; }
.rc-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }
.rc-body { white-space: pre-wrap; line-height: 1.7; }
.my-report { border: 1.5px solid var(--primary); border-radius: 8px; padding: 12px; margin: 10px 0; background: #f6fbf8; }
.my-report.done { border-color: var(--line); background: #fff; }
.mr-head { display: flex; gap: 8px; align-items: baseline; margin-bottom: 8px; }
.locked-input { background: #f3f4f6 !important; color: var(--text) !important; cursor: not-allowed; }
.rec-pick { display: flex; gap: 8px; flex-wrap: wrap; }
.rec-opt { margin: 0; cursor: pointer; }
.rec-opt input { display: none; }
.rec-opt .rec { padding: 6px 14px; font-size: 13px; opacity: .55; }
.rec-opt input:checked + .rec { opacity: 1; box-shadow: 0 0 0 2px currentColor; }
.decide-pick { display: flex; gap: 10px; margin-bottom: 10px; }
.dp { flex: 1; border: 1.5px solid var(--line-2); border-radius: 6px; padding: 10px; text-align: center; cursor: pointer; font-weight: 600; color: var(--text); margin: 0; }
.dp input { display: none; }
.dp.ok:has(input:checked) { border-color: var(--ok); background: var(--ok-soft); color: var(--ok); }
.dp.no:has(input:checked) { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }
.board-hist { border-inline-start: 3px solid var(--line-2); padding: 4px 10px; margin: 6px 0; font-size: 13px; }
.appdoc .sign.sign4 div { width: 23%; }

/* تفصيل الأقساط السابقة */
.prev-editor { border: 1px dashed var(--gold); border-radius: 6px; padding: 10px 12px; background: #fffdf6; }
.pe-head { margin-bottom: 8px; }
.pe-gen { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 8px; }
.pe-gen .field { margin: 0; }
.pe-table input { padding: 4px 6px; }
.pe-table td { padding: 4px 6px; }
.pe-table tr.pe-bad td { background: var(--danger-soft); }
.pe-sum { margin-top: 6px; font-size: 13px; }
.sheet td.legacy, td.legacy { background: #fffbeb; }
.legacy-key { background: #fffbeb; border: 1px solid #fde68a; padding: 0 6px; border-radius: 3px; }

/* التأخيرات: ما سُدد لاحقاً */
tr.row-settled td { color: #6b7280; }
tr.row-settled td .badge-ok { color: var(--ok); }
.ms-legacy { outline: 2px dotted #92400e; outline-offset: -1px; }

/* بناء خانات الملف */
.fields-table td { vertical-align: middle; }
.fields-table tr.f-hidden td { opacity: .55; background: #fafafa; }
.fields-table .btn-ghost[disabled] { visibility: hidden; }
.switch { position: relative; display: inline-block; width: 38px; height: 21px; margin: 0; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #d1d5db; border-radius: 21px; transition: .15s; }
.switch span::before { content: ''; position: absolute; width: 15px; height: 15px; top: 3px; inset-inline-start: 3px; background: #fff; border-radius: 50%; transition: .15s; }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::before { transform: translateX(-17px); }
[dir=ltr] .switch input:checked + span::before { transform: translateX(17px); }
.switch.locked { opacity: .5; cursor: not-allowed; }

/* الأقسام */
.dept-members { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.dm { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; }
.dm .check { margin: 0; }
.dept-add select { max-width: 360px; }
.perm-item.perm-locked { opacity: .5; }

/* سجل العمليات */
tr.audit-fail td { background: #fff7f7; }
code.jv { display: block; white-space: pre-wrap; font-size: 11px; max-height: 160px; overflow: auto; background: #f9fafb; padding: 4px 6px; border-radius: 3px; direction: ltr; text-align: left; }
.audit-detail .kv { margin-bottom: 6px; }
@media (max-width: 900px) { .kpi-row.kpi-6 { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 560px) { .kpi-row.kpi-6 { grid-template-columns: repeat(2, 1fr); } .top-btn { width: 34px; height: 34px; } }
@media print { .top-actions, .bell-panel { display: none !important; } }
.th-head h3 { flex: 1 1 60%; min-width: 180px; }
.th-head .btn-row { flex-wrap: wrap; }
#menu-btn { padding: 6px 8px; line-height: 0; }
#menu-btn .ico { width: 20px; height: 20px; }

/* ===== ملف القروض الشهري: منظم ومجمّع حسب المندوب، رؤوس وعمود اسم ثابتان، تمرير داخلي بالاتجاهين ===== */
.card-flush { padding: 0; overflow: hidden; }
.sheet-wrap { max-height: calc(100vh - 250px); min-height: 240px; overflow: auto; -webkit-overflow-scrolling: touch; }
table.msheet { border-collapse: separate; border-spacing: 0; font-size: 12.5px; width: max-content; min-width: 100%; }
table.msheet th, table.msheet td { border-bottom: 1px solid var(--line); border-inline-start: 1px solid #eef0f3; background: #fff; }
table.msheet thead th { position: sticky; top: 0; z-index: 3; background: #f3f4f6; color: #374151; border-bottom: 1px solid var(--line-2); }
table.msheet .stick { position: sticky; right: 0; z-index: 2; min-width: 190px; max-width: 260px; white-space: normal; border-inline-start: 0; box-shadow: inset -1px 0 0 var(--line-2); }
table.msheet thead th.stick { z-index: 4; background: #f3f4f6; }
table.msheet tbody tr.odd td { background: #fafbfc; }
table.msheet tbody tr:hover td { background: #f1f7f3; }
table.msheet tr.grp td { background: var(--primary-soft); color: var(--primary); font-weight: 700; border-top: 2px solid #cfe3d8; }
table.msheet tr.grp .grp-n { font-weight: 500; font-size: 11.5px; color: var(--muted); margin-inline-start: 6px; }
table.msheet tr.sub td { background: #f9fafb; font-weight: 600; color: #374151; }
table.msheet tfoot td { position: sticky; bottom: 0; z-index: 2; background: #eef2f0; font-weight: 700; border-top: 2px solid var(--line-2); }
table.msheet tfoot td.stick { z-index: 4; }
table.msheet th.cur, table.msheet td.cur { box-shadow: inset 0 0 0 1px rgba(26,93,58,.25); }
table.msheet thead th.cur { background: #e3efe8; color: var(--primary); }
table.msheet td.legacy { background: #fffbeb !important; }
table.msheet td.cell-pay { min-width: 64px; }
@media print { .sheet-wrap { max-height: none; overflow: visible; } table.msheet thead th, table.msheet .stick, table.msheet tfoot td { position: static; box-shadow: none; } .card-flush { overflow: visible; } }

/* شبكة الدفعات الشهرية في صفحة المقترض: أعمدة متساوية وخطوط فاصلة لتتطابق الخانات طولياً وعرضياً */
table.ygrid { border-collapse: collapse; table-layout: fixed; min-width: 860px; }
table.ygrid th, table.ygrid td { border: 1px solid var(--line); text-align: center; vertical-align: middle; padding: 6px 4px; line-height: 1.35; }
table.ygrid th:first-child, table.ygrid td:first-child { width: 64px; }
table.ygrid th:last-child, table.ygrid td:last-child { width: 96px; }
table.ygrid td.num, table.ygrid th.num { text-align: center; }

/* تقرير المندوب لعدة أشهر */
.doc-a4.doc-wide { max-width: 1400px; }
table.agent-sheet th, table.agent-sheet td { border: 1px solid var(--line); }
table.agent-sheet td.num { text-align: center; }
.btn .ico { width: 16px; height: 16px; vertical-align: -3px; margin-inline-end: 4px; }

/* كشف حساب المقترض */
.st-loan { margin: 6px 0 18px; break-inside: auto; }
.st-h { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 15.5px; color: var(--primary); margin: 12px 0 8px; }
.st-sum { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); border-radius: var(--radius); background: #f9fafb; margin-bottom: 8px; }
.st-sum div { padding: 8px 12px; border-inline-start: 1px solid var(--line); }
.st-sum div:first-child { border-inline-start: 0; }
.st-sum span { display: block; font-size: 12px; color: var(--muted); }
.st-sum b { font-size: 16px; }
table.st-table th, table.st-table td { border: 1px solid var(--line); padding: 6px 10px; }
table.st-table tr.legacy td { background: #fffbeb; }
@media print { .st-table tr { break-inside: avoid; } }
.intro-edit { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 10px; }
.intro-edit textarea { width: 100%; line-height: 1.8; }
.rc-sec { margin: 6px 0; }
.rc-label { font-size: 12.5px; font-weight: 600; color: var(--primary); margin-bottom: 2px; }
.appdoc .rp-sec { margin: 4px 0 6px; }
.appeals { margin-bottom: 10px; }
.appeal { border: 1px solid #fde68a; background: #fffdf3; border-radius: 6px; padding: 8px 12px; margin-bottom: 8px; }
.appeal.open { border-color: #f59e0b; box-shadow: 0 0 0 2px rgba(245,158,11,.12); }
.ap-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.ap-text { white-space: pre-wrap; line-height: 1.7; margin-top: 4px; }
.phone-row { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.phone-row .ph { flex: 1; direction: ltr; text-align: right; }

/* ===== الهاتف: لا يتجاوز أي محتوى عرض الشاشة؛ الجداول العريضة تتحرك أفقياً داخل إطارها ===== */
.grid > *, .form-grid > *, .kpi { min-width: 0; }
.kpi-value { overflow-wrap: anywhere; }
.kpi-row.kpi-auto { grid-template-columns: repeat(var(--n, 4), minmax(0, 1fr)); }
@media (max-width: 900px) { .kpi-row.kpi-auto { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) {
  .kpi-row.kpi-auto { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-row.kpi-auto .kpi { padding: 12px 14px; border-bottom: 1px solid var(--line); border-inline-end: 1px solid var(--line); }
  .kpi-row.kpi-auto .kpi:nth-child(2n) { border-inline-end: 0; }
  .kpi-row.kpi-auto .kpi-value { font-size: 20px; }
}
.table-wrap { -webkit-overflow-scrolling: touch; max-width: 100%; }
.top-logout { display: none; }
@media (max-width: 900px) { .top-logout { display: inline-flex; } }
@media screen and (max-width: 900px) {
  /* أزرار الاختيار تنزل لسطر جديد بدل أن تخرج عن الشاشة */
  .seg { flex-wrap: wrap; max-width: 100%; }
  .filters .field { min-width: 0 !important; max-width: 100%; }
  /* جداول التقارير (الأهلية، المتبرعين) تتحرك أفقياً داخل نفسها */
  table.elig-table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
  /* جداول البيانات في رأس المستندات: كل عنوان مع قيمته في سطر */
  table.doc-kv tr { display: flex; flex-wrap: wrap; }
  table.doc-kv td { flex: 1 1 60%; min-width: 0; overflow-wrap: anywhere; }
  table.doc-kv td.muted { flex: 0 0 34%; }
  .doc { padding: 14px; }
}
@media screen and (max-width: 560px) { .appdoc .kv2 { grid-template-columns: 1fr; } }
