/* إدارة الدين — تنسيقات الشاشات الداخلية */
.page-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.page-title { font-family: var(--font-head); font-size: 25px; font-weight: 700; line-height: 1.3; }
.page-sub { color: var(--muted); font-size: 13.5px; }
.section-title { font-family: var(--font-head); font-size: 18px; font-weight: 600; margin-bottom: 10px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.grid-charts { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.span-2 { grid-column: span 2; }
@media (max-width: 780px) { .span-2 { grid-column: span 1; } }

/* ── الإجراءات السريعة ── */
.quick-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(112px, 1fr)); gap: 10px; }
.quick-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px;
  padding: 13px 8px; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer; font-family: inherit;
  font-size: 13.5px; font-weight: 600; min-height: 82px;
  transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease;
}
.quick-btn:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--border-strong); }
.quick-btn .qi {
  width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary);
}
.quick-btn.q-neg .qi { background: var(--neg-soft); color: var(--neg); }
.quick-btn.q-pos .qi { background: var(--pos-soft); color: var(--pos); }
.quick-btn.q-warn .qi { background: var(--warn-soft); color: var(--warn); }

/* ── أدوات الفلترة ── */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.search-box { position: relative; flex: 1; min-width: 220px; }
.search-box .ic { position: absolute; inset-inline-start: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search-box input { padding-inline-start: 40px; background: var(--surface); }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 3px; gap: 2px; }
.seg button {
  border: none; background: transparent; font-family: inherit; font-size: 13px; font-weight: 600;
  color: var(--muted); padding: 7px 13px; border-radius: 9px; cursor: pointer; min-height: 38px; white-space: nowrap;
  transition: background .16s, color .16s;
}
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }
.seg-wrap { overflow-x: auto; max-width: 100%; padding-bottom: 2px; }

/* ── كشف الحساب ── */
.ledger-toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.summary-card {
  border-radius: var(--radius-lg); padding: 20px; border: 1px solid var(--border);
  background: var(--surface); box-shadow: var(--shadow-sm);
}
.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.summary-cell { text-align: center; padding: 12px; border-radius: var(--radius); background: var(--surface-2); }
.summary-cell .lbl { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.summary-cell .v { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 3px; }
.net-box { margin-top: 16px; border-radius: var(--radius); padding: 18px; text-align: center; border: 1px solid var(--border); }
.net-box.neg { background: var(--neg-soft); border-color: color-mix(in srgb, var(--neg) 30%, transparent); }
.net-box.pos { background: var(--pos-soft); border-color: color-mix(in srgb, var(--pos) 30%, transparent); }
.net-box.neutral-state { background: var(--surface-2); }
.net-box .net-v { font-size: clamp(30px, 5vw, 42px); font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.net-label { display: inline-flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 700; }

/* ── الرسوم البيانية ── */
.chart-box { width: 100%; position: relative; }
.chart-svg { width: 100%; display: block; overflow: visible; }
.chart-tip {
  position: absolute; pointer-events: none; z-index: 5; background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: 10px; padding: 7px 10px;
  font-size: 12.5px; box-shadow: var(--shadow); opacity: 0; transition: opacity .14s;
  white-space: nowrap; direction: rtl;
}
.chart-tip.on { opacity: 1; }
.chart-tip b { display: block; font-size: 13.5px; margin-bottom: 2px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; font-size: 12.5px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.chart-empty { display: grid; place-items: center; height: 180px; color: var(--muted); font-size: 13.5px; }
.rank-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px dashed var(--border); }
.rank-row:last-child { border-bottom: none; }
.rank-idx { width: 24px; height: 24px; border-radius: 8px; background: var(--surface-2); display: grid; place-items: center; font-size: 12px; font-weight: 700; color: var(--muted); flex: none; }
.rank-bar { flex: 1; min-width: 60px; }
.rank-val { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ── الإيصالات ── */
.receipt {
  background: #fff; color: #0F172A; border-radius: var(--radius);
  padding: 20px; border: 1px dashed var(--border-strong); max-width: 420px; margin: 0 auto;
}
.receipt-head { text-align: center; border-bottom: 1px dashed #C6D1E2; padding-bottom: 10px; margin-bottom: 12px; }
.receipt-head .rn { font-family: var(--font-head); font-size: 20px; font-weight: 700; }
.receipt-row { display: flex; justify-content: space-between; padding: 5px 0; font-size: 13.5px; }
.receipt-row .k { color: #64748B; }
.receipt-row .v { font-weight: 700; }
.receipt-total { border-top: 2px solid #0F172A; margin-top: 10px; padding-top: 8px; font-size: 17px; }
.receipt-foot { text-align: center; font-size: 11.5px; color: #64748B; margin-top: 14px; border-top: 1px dashed #C6D1E2; padding-top: 8px; }

/* ── البحث والمساعد والتنبيهات ── */
.result-item { display: flex; align-items: center; gap: 11px; padding: 11px; border-radius: var(--radius-sm); cursor: pointer; border: 1px solid transparent; }
.result-item:hover { background: var(--surface-2); border-color: var(--border); }
.result-title { font-weight: 600; font-size: 14.5px; }
.result-sub { font-size: 12.5px; color: var(--muted); }
.insight { display: flex; gap: 11px; padding: 13px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); }
.insight .ii { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; flex: none; background: var(--primary-soft); color: var(--primary); }
.insight.pos .ii { background: var(--pos-soft); color: var(--pos); }
.insight.neg .ii { background: var(--neg-soft); color: var(--neg); }
.insight.warn .ii { background: var(--warn-soft); color: var(--warn); }
.notif { display: flex; gap: 11px; padding: 12px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); }
.notif.unread { border-inline-start: 4px solid var(--primary); }
.notif-sev-neg { color: var(--neg); } .notif-sev-warn { color: var(--warn); }
.notif-sev-pos { color: var(--pos); } .notif-sev-info { color: var(--primary); }
.phone-txt { direction: ltr; unicode-bidi: embed; font-variant-numeric: tabular-nums; }
@media print { .sidebar, .topbar, .tabbar, .fab, .toasts { display: none !important; } }

/* ── تفاصيل إضافية ── */
.totals { font-size: 14px; }
.totals > div { display: flex; justify-content: space-between; padding: 5px 0; border-bottom: 1px dashed var(--border); }
.totals > div:last-child { border-bottom: none; font-size: 17px; }
.field.full .hint { display: block; }
body.hide-balances .amount, body.hide-balances .kpi-value, body.hide-balances .net-v, body.hide-balances .rank-val, body.hide-balances td.num {
  filter: blur(7px); transition: filter .18s ease;
}
body.hide-balances .amount:hover, body.hide-balances .kpi-value:hover, body.hide-balances .net-v:hover,
body.hide-balances .rank-val:hover, body.hide-balances td.num:hover { filter: none; }
.insight .result-sub b { color: var(--text); }
@media (max-width: 520px) {
  .summary-cell .v { font-size: 21px; }
  .net-box .net-v { font-size: 28px; }
  table.data { min-width: 560px; }
}
