/* ==========================================================================
   أنماط الملخص + الديون + الفواتير — تصميم جدولي مضغوط بنفس فلسفة المصاريف
   ========================================================================== */

/* ---------- الملخص: بطاقتان في كل صف + عناوين قابلة للتحرير ---------- */
.cards.two{ grid-template-columns:repeat(2, 1fr); }
@media (min-width:700px){ .cards.two{ grid-template-columns:repeat(4, 1fr); } }
.cards.two .card{ padding:10px 12px; }
.cards.two .card .lbl span[contenteditable]{
  border-radius:5px; padding:0 3px; outline:none; cursor:text;
}
.cards.two .card .lbl span[contenteditable]:hover{ background:var(--green-soft); }
.cards.two .card .lbl span[contenteditable]:focus{ background:#FBFDF9; box-shadow:0 0 0 1.5px var(--green); }
.cards.two .card.hi .lbl span[contenteditable]:hover{ background:rgba(255,255,255,.15); }
.cards.two .card.hi .lbl span[contenteditable]:focus{ background:rgba(255,255,255,.1); box-shadow:0 0 0 1.5px #fff; }
.cards.two .card .val{ font-size:18px; }
.ind-note{ font-size:11px; color:var(--muted); font-weight:400; }

/* ---------- شرائح إحصائية ---------- */
.stat-chips{ display:grid; grid-template-columns:repeat(auto-fit, minmax(120px,1fr)); gap:6px; margin-bottom:12px; }
.stat-chips .sc{
  display:flex; justify-content:space-between; align-items:baseline; gap:8px;
  background:var(--card); border:1px solid var(--line); border-radius:8px; padding:6px 10px;
}
.stat-chips .sc span{ font-size:11px; color:var(--muted); }
.stat-chips .sc b{ font-size:13.5px; font-variant-numeric:tabular-nums; }
.stat-chips .sc.hi{ background:var(--green); border-color:var(--green); }
.stat-chips .sc.hi span{ color:#CFE3DC; }
.stat-chips .sc.hi b{ color:#fff; }

/* ---------- صفوف الديون والفواتير (جدولية مضغوطة) ---------- */
.d-row{
  display:flex; flex-wrap:wrap; align-items:center; gap:3px 8px;
  border-top:1px solid var(--line); padding:3px 10px; font-size:13px;
}
.d-row .dc{ display:flex; align-items:center; gap:4px; min-width:0; }
.d-row .dc.name{ flex:1 1 120px; }
.d-row .dc.name input{ font-weight:600; width:100%; }
.d-row input[type=text], .d-row select{
  border:1px solid transparent; background:transparent; font-family:inherit;
  font-size:13px; padding:5px; border-radius:6px; color:var(--ink); min-width:0;
}
.d-row input:focus, .d-row select:focus{ outline:none; border-color:var(--green); background:#FBFDF9; }
.d-row input.mny{ width:76px; direction:ltr; text-align:center; font-variant-numeric:tabular-nums; }
.d-row input.cnt{ width:44px; direction:ltr; text-align:center; font-variant-numeric:tabular-nums; }
.d-row .fl{ font-size:9.5px; color:var(--muted); white-space:nowrap; }
.d-row .dc.ro b{ font-size:12.5px; font-variant-numeric:tabular-nums; }
.d-row .del{ border:none; background:none; cursor:pointer; font-size:13.5px; padding:3px 5px; color:#B9C2BD; border-radius:6px; line-height:1; }
.d-row .del:hover{ color:var(--danger); background:var(--danger-soft); }
.d-row .dc.act{ gap:3px; }
.d-mini{
  border:1px solid var(--line); background:var(--card); font-family:inherit;
  font-size:11.5px; padding:4px 8px; border-radius:6px; cursor:pointer; color:var(--ink); white-space:nowrap;
}
.d-mini:hover{ border-color:var(--green); }
.d-mini.ok{ background:var(--green-soft); border-color:var(--green); color:var(--green); font-weight:600; }
.d-mini.miss{ background:var(--danger-soft); border-color:var(--danger-soft); color:var(--danger); }
.d-st{ font-size:11.5px; font-weight:700; border-radius:999px; padding:3px 10px; white-space:nowrap; }
.d-st.ok{ background:var(--green-soft); color:var(--green); }
.d-st.part{ background:var(--gold-soft); color:#8A6D0F; }
.d-st.miss{ background:var(--danger-soft); color:var(--danger); }

/* السطر الثانوي (النوع + الملاحظة + الحذف): يظهر عند التحرير فقط على الجوال */
.d-row .dc.sub2{ flex:1 1 100%; gap:4px; }
.d-row .dc.sub2 input{ flex:1; font-size:12px; color:var(--muted); }

/* كشف عمليات الدين الكبير */
.d-row .txwrap{ flex:1 1 100%; font-size:12px; }
.d-row .txwrap summary{ cursor:pointer; color:var(--muted); padding:2px 0; list-style:none; }
.d-row .txwrap summary::-webkit-details-marker{ display:none; }
.d-row .txwrap summary::before{ content:'▾ '; color:var(--green); font-size:10px; }
.tx{ display:flex; flex-wrap:wrap; align-items:baseline; gap:4px 10px; padding:4px 8px; border-radius:6px; margin:2px 0; }
.tx.txb{ background:var(--danger-soft); }
.tx.txr{ background:var(--green-soft); }
.tx .txk{ font-weight:700; font-size:11.5px; }
.tx.txb .txk{ color:var(--danger); }
.tx.txr .txk{ color:var(--green); }
.tx b{ font-variant-numeric:tabular-nums; }
.tx .txw{ color:var(--muted); font-size:11px; }
.tx .txba{ color:var(--muted); font-size:11px; margin-inline-start:auto; }
.tx .txn{ color:var(--muted); font-size:11px; flex:1 1 100%; }

/* سجل عمليات الديون */
.exp-log-item2{
  display:flex; flex-wrap:wrap; align-items:baseline; gap:4px 10px;
  background:var(--card); border:1px solid var(--line); border-radius:8px;
  padding:6px 10px; margin-bottom:5px; font-size:12px;
}
.exp-log-item2 b{ font-variant-numeric:tabular-nums; }
.exp-log-item2 .txn{ color:var(--muted); }

/* ---------- الفواتير ---------- */
.pp-chips{ display:flex; flex-wrap:wrap; gap:6px; margin:10px 0 12px; }
.pp-chip{
  display:inline-flex; align-items:center; gap:8px; border:1px solid var(--line);
  background:var(--card); border-radius:999px; padding:6px 12px; cursor:pointer;
  font-family:inherit; font-size:12.5px; color:var(--ink);
}
.pp-chip:hover{ border-color:var(--green); }
.pp-chip b{ color:var(--green); font-variant-numeric:tabular-nums; }
.pp-chip .pp-doc{ font-size:11px; }

.grp{ border-top:1px solid var(--line); padding:4px 10px; }
.grp summary{ display:flex; align-items:center; gap:8px; cursor:pointer; list-style:none; padding:3px 0; }
.grp summary::-webkit-details-marker{ display:none; }
.grp summary::before{ content:'▾'; color:var(--green); font-size:10px; }
.grp summary input{ font-weight:600; border:1px solid transparent; background:transparent; font-family:inherit; font-size:13px; padding:4px; border-radius:6px; flex:1; min-width:0; }
.grp summary input:focus{ outline:none; border-color:var(--green); background:#FBFDF9; }
.grp-body{ padding:4px 0 8px; }
.grp-m{ display:flex; gap:6px; align-items:center; padding:2px 0; }
.grp-m input{ border:1px solid var(--line); border-radius:6px; font-family:inherit; font-size:12.5px; padding:5px 7px; }
.grp-m input:first-child{ flex:1; min-width:0; }
.grp-m input.mny{ width:80px; direction:ltr; text-align:center; }
.grp-apply{ display:flex; gap:6px; align-items:center; flex-wrap:wrap; padding-top:6px; }
.grp-apply .sel-mini{ border:1px solid var(--line); border-radius:6px; font-family:inherit; padding:5px !important; }

/* ---------- شريط التنبيهات الذكي (الملخص) ---------- */
.alert-strip{ display:flex; gap:6px; flex-wrap:wrap; margin-bottom:10px; }
.alert-strip .al{
  border:1px solid var(--line); background:var(--card); border-radius:999px;
  padding:6px 12px; font-family:inherit; font-size:12px; cursor:pointer; color:var(--ink);
  box-shadow:var(--shadow-sm);
}
.alert-strip .al:hover{ border-color:var(--green); }
.alert-strip .al.ok{ background:var(--green-soft); border-color:var(--green-soft); color:var(--green); }
.alert-strip .al.warn{ background:var(--warn-soft); border-color:var(--warn-soft); color:var(--warn); }
.alert-strip .al.bad{ background:var(--danger-soft); border-color:var(--danger-soft); color:var(--danger); }

/* ---------- كتلة قسم (عنوان + بطاقات) ---------- */
.sec-block{ margin-bottom:16px; }
.sec-block-h{ display:flex; align-items:center; gap:8px; flex-wrap:wrap; padding:2px 4px 7px; }
.sec-block-h .sbt{ font-weight:700; color:var(--green); font-size:13.5px; }

/* ---------- البطاقة التفاعلية (ديون / فواتير) ---------- */
.d-card{
  background:var(--card); border:1px solid var(--line); border-radius:13px;
  margin-bottom:7px; box-shadow:var(--shadow-sm); overflow:hidden;
  transition:box-shadow .12s ease;
}
.d-card:hover{ box-shadow:var(--shadow); }
.d-card.open{ box-shadow:var(--shadow); }
.dch{ display:flex; align-items:center; gap:9px; padding:10px 12px; cursor:pointer; user-select:none; }
.dch-car{ font-size:10px; color:var(--muted); flex:0 0 auto; }
.dch-main{ flex:1; min-width:0; }
.dch-name{ font-weight:600; font-size:13.5px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.dch-type{ font-size:10px; font-weight:500; color:var(--muted); background:var(--bg); border-radius:999px; padding:2px 8px; margin-inline-start:4px; }
.dch-sub{ font-size:11px; color:var(--muted); margin-top:1px; font-variant-numeric:tabular-nums; }
.dch-bal{ font-size:15px; font-variant-numeric:tabular-nums; color:var(--ink); flex:0 0 auto; }
.d-card.open .dch{ background:var(--green-soft); }

.dcb{ padding:10px 12px 12px; border-top:1px solid var(--line); }
.dcb-actions{ display:flex; gap:6px; flex-wrap:wrap; align-items:center; margin-bottom:10px; }
.dcb-actions .del{ margin-inline-start:auto; border:none; background:none; cursor:pointer; color:#B9C2BD; font-size:12px; font-family:inherit; padding:4px 7px; border-radius:6px; }
.dcb-actions .del:hover{ color:var(--danger); background:var(--danger-soft); }
.dcb-fields{ display:grid; grid-template-columns:repeat(auto-fit, minmax(140px,1fr)); gap:7px; margin-bottom:8px; }
.dcb-fields label{ display:flex; flex-direction:column; gap:2px; }
.dcb-fields label.wide{ grid-column:1 / -1; }
.dcb-fields label > span{ font-size:10px; color:var(--muted); }
.dcb-fields input, .dcb-fields select{
  border:1px solid var(--line); background:#fff; font-family:inherit; font-size:13px;
  padding:6px 8px; border-radius:8px; color:var(--ink); width:100%;
}
.dcb-fields input:focus, .dcb-fields select:focus{ outline:none; border-color:var(--green); }
.dcb-fields input.mny{ direction:ltr; text-align:center; font-variant-numeric:tabular-nums; }
.dcb-hist{ border-top:1px dashed var(--line); padding-top:8px; }
.dcb-hist-t{ font-size:11px; font-weight:600; color:var(--muted); margin-bottom:5px; }

/* صف ربط شخص داخل بطاقة الفاتورة */
.bl-row{ display:flex; gap:4px; align-items:center; flex-wrap:wrap; padding:3px 0; border-bottom:1px dashed var(--line); }
.bl-row:last-of-type{ border-bottom:none; }
.bl-row input{
  border:1px solid transparent; background:transparent; font-family:inherit; font-size:12.5px;
  padding:5px 6px; border-radius:6px; color:var(--ink); min-width:0;
}
.bl-row input:focus{ outline:none; border-color:var(--green); background:#FBFDF9; }
.bl-row input:first-child{ flex:1 1 90px; font-weight:600; }
.bl-row input.mny{ width:70px; direction:ltr; text-align:center; font-variant-numeric:tabular-nums; }
.bl-row input.dt{ width:84px; font-size:11px; color:var(--muted); }
.bl-row input:nth-child(3), .bl-row input:nth-child(6){ flex:1 1 80px; font-size:11.5px; color:var(--muted); }
.bl-row .del{ border:none; background:none; cursor:pointer; color:#B9C2BD; font-size:13px; padding:3px 5px; border-radius:6px; }
.bl-row .del:hover{ color:var(--danger); }
.pp-title{ font-size:12px; font-weight:600; color:var(--green); margin:2px 2px 6px; }
.pp-title span{ font-weight:400; color:var(--muted); font-size:10.5px; }
.arch-seq{ font-size:10px; color:var(--muted); font-weight:400; }

/* ---------- جوال ---------- */
@media (max-width:820px){
  .d-row{ padding:3px 8px; }
  .d-row .dc.sub2{ display:none; }
  .d-row:focus-within .dc.sub2{ display:flex; flex-wrap:wrap; }
  .d-row .fl{ display:none; }
  .d-row:focus-within .fl{ display:inline; }
  .cards.two .card .val{ font-size:16px; }
  .dch{ padding:9px 10px; }
  .dch-bal{ font-size:14px; }
  .dcb-fields{ grid-template-columns:repeat(2, 1fr); }
  .bl-row input.dt{ width:74px; }
}
