/* تجربة «أنشئ فاتورة» التفاعلية: نافذة بشكل النظام الأبيض، تعمل في المتصفح فقط ببيانات وهمية. نطاق الأسماء idm-. */
.idm-open-btn { display: inline-flex; align-items: center; gap: 10px; margin: 0 0 18px; padding: 10px 18px 10px 14px; border: 1.5px solid #bfd6f6; border-radius: 14px; background: #fff; color: #1d4ed8; font: inherit; font-size: .95rem; font-weight: 800; cursor: pointer; box-shadow: 0 10px 24px -16px rgba(29, 78, 216, .6); transition: transform .2s, box-shadow .2s, border-color .2s; }
.idm-open-btn:hover { transform: translateY(-2px); border-color: #2563eb; box-shadow: 0 16px 30px -16px rgba(29, 78, 216, .7); }
.idm-open-btn:focus-visible { outline: 3px solid #93c5fd; outline-offset: 3px; }
.idm-open-btn .idm-play { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: #2563eb; color: #fff; }
.idm-open-btn .idm-play svg { width: 13px; height: 13px; margin-inline-start: 2px; }
.dark .idm-open-btn { background: #1e293b; border-color: #334155; color: #93c5fd; }
/* رابط صفحة «إدخال البيانات بالذكاء الاصطناعي» تحت زر التجربة */
.idm-ai-link { display: table; margin: -8px 0 18px; padding: 4px 2px; color: #6d28d9; font-size: .9rem; font-weight: 700; text-decoration: none; }
.idm-ai-link:hover { text-decoration: underline; }
.idm-ai-link:focus-visible { outline: 3px solid #c4b5fd; outline-offset: 2px; border-radius: 6px; }
.dark .idm-ai-link { color: #c4b5fd; }


/* ===== نافذة التجربة: نسخة من واجهة النظام ===== */
.idm-root { --b: #2563eb; --b-d: #1d4ed8; --band: #1262e6; --ink: #0f172a; --mut: #64748b; --line: #dfe6ef; --soft: #f6f8fb; --teal: #0b6aa2; --ok: #16a34a;
    position: fixed; inset: 0; z-index: 2147483000; display: none; align-items: center; justify-content: center; padding: 18px; background: rgba(15, 23, 42, .68);
    font-family: 'Segoe UI', Tahoma, 'Noto Sans Arabic', system-ui, -apple-system, sans-serif; font-size: 14px; line-height: 1.5; color: var(--ink); -webkit-font-smoothing: antialiased; }
.idm-root *, .idm-root *::before, .idm-root *::after { box-sizing: border-box; }
.idm-root.is-open { display: flex; animation: idm-fade .25s ease-out; }
@keyframes idm-fade { from { opacity: 0; } to { opacity: 1; } }
.idm-i { width: 18px; height: 18px; flex: none; display: block; }
.idm-win { position: relative; display: flex; width: min(1260px, 100%); height: min(800px, 100%); overflow: hidden; border-radius: 18px; background: #fff; box-shadow: 0 40px 90px -30px rgba(0, 0, 0, .6); animation: idm-rise .35s cubic-bezier(.16, .84, .28, 1); }
@keyframes idm-rise { from { opacity: 0; transform: translateY(18px) scale(.985); } to { opacity: 1; transform: none; } }

/* القائمة الجانبية */
.idm-side { flex: none; width: 218px; display: flex; flex-direction: column; gap: 3px; padding: 14px 12px; border-inline-start: 1px solid var(--line); background: #fff; overflow: hidden; }
.idm-side img { display: block; width: 136px; margin: 4px auto 14px; }
.idm-nav { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; color: #334155; font-size: .86rem; font-weight: 500; white-space: nowrap; }
.idm-nav .idm-i { width: 19px; height: 19px; color: #475569; }
.idm-nav span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.idm-nav-c { width: 14px !important; height: 14px !important; color: #64748b !important; }
.idm-nav.is-on { background: var(--b); color: #fff; box-shadow: 0 8px 16px -8px rgba(37, 99, 235, .85); }
.idm-nav.is-on .idm-i { color: #fff; }
.idm-nav.is-on .idm-nav-c { color: #fff !important; }

.idm-main { position: relative; flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--soft); }
.idm-scroll { flex: 1; min-height: 0; overflow: auto; padding: 16px 20px 130px; }
.idm-main.is-form .idm-scroll { padding-bottom: 110px; }
.idm-card { margin-bottom: 14px; padding: 18px 20px; border: 1px solid #e8edf4; border-radius: 16px; background: #fff; box-shadow: 0 8px 22px -16px rgba(15, 23, 42, .4); }
.idm-num { font-variant-numeric: tabular-nums; }
.idm-sp { flex: 1; }

/* أزرار */
.idm-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px; border: 1px solid var(--line); border-radius: 9px; background: #fff; color: #1e293b; font: inherit; font-size: .9rem; font-weight: 600; cursor: pointer; white-space: nowrap; transition: background-color .15s, border-color .15s, box-shadow .15s; text-decoration: none; }
.idm-btn .idm-i { width: 17px; height: 17px; }
.idm-btn:hover { background: #f1f5f9; }
.idm-btn[disabled] { opacity: .45; cursor: not-allowed; }
.idm-btn.is-primary { background: var(--b); border-color: var(--b); color: #fff; box-shadow: 0 8px 16px -10px rgba(37, 99, 235, .9); }
.idm-btn.is-primary:hover { background: var(--b-d); }
.idm-btn.is-green { background: var(--ok); border-color: var(--ok); color: #fff; }
.idm-btn.is-green:hover { background: #15803d; }
.idm-btn.is-outline { border-color: #93c5fd; color: var(--b-d); background: #fff; }
.idm-btn.is-outline:hover { background: #eff6ff; }
.idm-btn.is-ghost-ok { border-color: #86efac; color: #15803d; background: #fff; cursor: default; }
.idm-btn.is-ghost-b { border-color: #93c5fd; color: var(--b-d); cursor: default; }
.idm-btn.is-ghost-r { border-color: #fca5a5; color: #dc2626; background: #fff; }
.idm-full { width: 100%; }
.idm-btn:focus-visible, .idm-ibtn:focus-visible, .idm-bb:focus-visible, .idm-opt:focus-visible, .idm-close:focus-visible { outline: 3px solid #93c5fd; outline-offset: 2px; }
.idm-ibtn { display: grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: 8px; background: transparent; color: #64748b; cursor: pointer; }
.idm-ibtn:hover { background: #eef2f7; }
.idm-ibtn .idm-i { width: 18px; height: 18px; }
.idm-pulse { animation: idm-pulse 1.9s ease-in-out infinite; }
@keyframes idm-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0); } 50% { box-shadow: 0 0 0 5px rgba(37, 99, 235, .3); } }

/* ===== قائمة الفواتير ===== */
.idm-page { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.idm-appbar { display: flex; align-items: center; gap: 10px; margin: 10px 20px 0; padding: 8px 12px; border-radius: 14px; background: #fff; box-shadow: 0 6px 18px -14px rgba(15, 23, 42, .5); }
.idm-srch { display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 10px; color: #475569; font-size: .86rem; }
.idm-blue { color: #2563eb; }
.idm-branch { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 12px; background: #eef3fa; font-size: .86rem; font-weight: 600; }
.idm-branch b { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: #3b82f6; color: #fff; font-size: .8rem; }
.idm-branch .idm-i { width: 14px; height: 14px; color: #64748b; }
.idm-ab-i { position: relative; display: grid; place-items: center; width: 34px; height: 34px; color: #334155; }
.idm-ab-i em { position: absolute; top: 0; inset-inline-end: 0; display: grid; place-items: center; width: 17px; height: 17px; border-radius: 50%; background: #ef4444; color: #fff; font-size: .65rem; font-style: normal; font-weight: 700; }
.idm-appbar .idm-chip { margin-inline-start: auto; padding: 5px 12px; border-radius: 999px; background: #eff6ff; color: var(--b-d); font-size: .75rem; font-weight: 800; white-space: nowrap; }
.idm-close { display: grid; place-items: center; width: 38px; height: 38px; border: 0; border-radius: 50%; background: #f1f5f9; color: #334155; cursor: pointer; }
.idm-close:hover { background: #e2e8f0; }
.idm-titlecard { display: flex; align-items: center; gap: 12px; margin: 12px 20px 0; padding: 14px 18px 8px; background: #fff; border-radius: 14px 14px 0 0; }
.idm-tc-i { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: #e8f0fe; color: var(--b); }
.idm-tc-i .idm-i { width: 24px; height: 24px; }
.idm-titlecard h2 { margin: 0; font-size: 1.5rem; font-weight: 800; line-height: 1.2; }
.idm-titlecard small { color: var(--mut); }
.idm-tabs { display: flex; gap: 4px; margin: 0 20px; padding: 6px 10px; overflow: hidden; background: #fff; border-top: 1px solid #edf1f6; border-bottom: 1px solid #e3e9f1; border-radius: 0 0 14px 14px; }
.idm-tabs span { display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 9px; color: #475569; font-size: .84rem; font-weight: 600; white-space: nowrap; }
.idm-tabs span .idm-i { width: 16px; height: 16px; }
.idm-tabs span.is-on { background: #fff; color: var(--ink); box-shadow: 0 2px 8px -2px rgba(15, 23, 42, .25); border: 1px solid #e5eaf1; }
.idm-lc-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.idm-lc-t { display: flex; align-items: baseline; gap: 12px; }
.idm-lc-t h3 { margin: 0; font-size: 1.7rem; font-weight: 800; }
.idm-lc-t small { color: var(--mut); font-size: .9rem; }
.idm-lc-b { display: flex; gap: 8px; }
.idm-filters { margin: 16px 0; padding: 14px 16px; border-radius: 12px; background: #f6f8fb; display: grid; gap: 10px; }
.idm-fr { display: flex; gap: 10px; align-items: flex-end; }
.idm-fl { flex: 1; min-width: 0; }
.idm-fl small { display: block; margin-bottom: 3px; color: #64748b; font-size: .75rem; }
.idm-fi { display: flex; align-items: center; justify-content: space-between; min-height: 38px; padding: 0 10px; border: 1px solid #d5dde8; border-radius: 9px; background: #fff; color: #334155; font-size: .86rem; }
.idm-fi .idm-i { width: 14px; height: 14px; color: #64748b; }
.idm-tw { overflow: auto; border: 1px solid #e5eaf1; border-radius: 12px; }
.idm-lt { width: 100%; border-collapse: collapse; font-size: .86rem; }
.idm-lt th { padding: 12px; background: #fff; border-bottom: 1px solid #e5eaf1; color: #1e293b; font-weight: 700; text-align: start; white-space: nowrap; }
.idm-lt td { padding: 11px 12px; border-bottom: 1px solid #eef2f7; vertical-align: middle; white-space: nowrap; }
.idm-lt tr.is-new td { background: #eff6ff; animation: idm-flash 1.6s ease-out; }
@keyframes idm-flash { from { background: #bfdbfe; } to { background: #eff6ff; } }
.idm-lk { color: var(--b-d); font-weight: 700; }
.idm-ent { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; }
.idm-ent .idm-i { width: 15px; height: 15px; }
.idm-badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .75rem; font-weight: 700; }
.idm-badge.ok { background: #dcfce7; color: #15803d; }
.idm-badge.no { background: #fee2e2; color: #b91c1c; }
.idm-acts { width: 60px; }
.idm-wrap { position: relative; }
.idm-pop { position: absolute; inset-inline-start: 0; top: 100%; z-index: 30; min-width: 190px; padding: 6px; border: 1px solid var(--line); border-radius: 12px; background: #fff; box-shadow: 0 18px 40px -16px rgba(15, 23, 42, .5); }
.idm-pop button { display: flex; align-items: center; gap: 8px; width: 100%; padding: 9px 12px; border: 0; border-radius: 8px; background: transparent; font: inherit; font-size: .86rem; text-align: start; cursor: pointer; color: #1e293b; }
.idm-pop button:hover, .idm-pop button:focus-visible { background: #eff6ff; outline: none; }
.idm-pop button.is-main { color: var(--b-d); font-weight: 700; }
.idm-pop .idm-i { width: 16px; height: 16px; }

/* ===== نموذج الفاتورة ===== */
.idm-band { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 24px; background: var(--band); color: #fff; }
.idm-band-t b { display: block; font-size: 1.35rem; font-weight: 800; line-height: 1.3; }
.idm-band-t span { display: block; margin-top: 2px; font-size: .85rem; opacity: .92; }
.idm-band-b { display: flex; align-items: center; gap: 6px; }
.idm-bb { display: grid; place-items: center; width: 38px; height: 38px; border: 0; border-radius: 10px; background: transparent; color: #fff; cursor: pointer; }
.idm-bb:hover { background: rgba(255, 255, 255, .16); }
.idm-bb .idm-i { width: 20px; height: 20px; }
.idm-bb-l { color: #475569; }
.idm-bb-l:hover { background: #eef2f7; }
.idm-fg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 24px; align-items: start; }
.idm-lbl { display: block; margin-bottom: 6px; color: #1e293b; font-size: .9rem; font-weight: 600; }
.idm-search { display: flex; align-items: center; gap: 8px; height: 42px; padding: 0 8px 0 10px; border: 1px solid #c9d3e0; border-radius: 10px; background: #fff; color: #64748b; }
.idm-search:focus-within { outline: 2px solid #a855f7; outline-offset: 1px; border-color: #a855f7; box-shadow: 0 0 0 4px rgba(168, 85, 247, .18); }
.idm-search .idm-i { width: 17px; height: 17px; }
.idm-search input { flex: 1; min-width: 0; height: 100%; border: 0; background: transparent; outline: none; font: inherit; font-size: .9rem; color: var(--ink); }
.idm-search input::placeholder { color: #8493a8; }
.idm-search kbd { padding: 3px 8px; border-radius: 6px; background: #e2e8f0; color: #94a3b8; font: inherit; font-size: .78rem; font-weight: 700; }
.idm-sel, .idm-date { display: flex; align-items: center; justify-content: space-between; gap: 8px; height: 42px; padding: 0 12px; border: 1px solid #c9d3e0; border-radius: 10px; background: #fff; color: var(--ink); font-size: .9rem; }
.idm-sel.is-ph, .idm-date.is-ph { color: #8493a8; }
.idm-sel .idm-i { width: 15px; height: 15px; color: #64748b; }
.idm-date { padding-inline-end: 0; overflow: hidden; }
.idm-date .idm-i { box-sizing: content-box; width: 20px; height: 20px; padding: 11px 12px; border-inline-start: 1px solid #e2e8f0; background: #f1f5f9; color: #475569; }
.idm-credit { display: flex; align-items: center; gap: 10px; margin-top: 8px; padding: 9px 12px; border: 1px solid #bfdbfe; border-radius: 9px; background: #eff6ff; color: #334155; font-size: .78rem; }
.idm-credit .idm-i { width: 18px; height: 18px; color: var(--b); }
.idm-menu { position: absolute; top: calc(100% + 4px); inset-inline: 0; z-index: 40; max-height: 300px; overflow: auto; padding: 6px; border: 1px solid #dbe3ee; border-radius: 12px; background: #fff; box-shadow: 0 22px 44px -18px rgba(15, 23, 42, .55); }
.idm-opt { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px; background: transparent; color: var(--ink); font: inherit; font-size: .88rem; text-align: start; cursor: pointer; }
.idm-opt span:first-child { font-weight: 600; }
.idm-opt small { color: #64748b; font-size: .76rem; }
.idm-opt .idm-ps { display: flex; flex-direction: column; align-items: flex-end; }
.idm-opt .idm-ps b { color: var(--b); font-size: .8rem; }
.idm-opt .idm-st { grid-column: 1 / -1; color: #15803d; }
.idm-opt:hover, .idm-opt.is-hl { background: #eff6ff; }
.idm-opt-add { display: flex; align-items: center; gap: 8px; margin-top: 4px; border-top: 1px solid #eef2f7; border-radius: 0 0 8px 8px; color: var(--b-d); font-weight: 700; }
.idm-opt-add .idm-i { width: 16px; height: 16px; }
.idm-nores { padding: 12px; text-align: center; }
.idm-nores p { margin: 0 0 8px; color: #64748b; font-size: .9rem; }

.idm-ih { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.idm-ih h3 { margin: 0; color: var(--teal); font-size: 1.5rem; font-weight: 800; }
.idm-thead, .idm-ir { display: grid; grid-template-columns: 34px 24px minmax(170px, 1.7fr) minmax(104px, 1fr) 66px 70px 92px 98px 118px 34px; gap: 8px; align-items: center; }
.idm-thead { padding: 8px 4px; color: var(--teal); font-size: .86rem; font-weight: 700; text-align: center; border-bottom: 1px solid #e5eaf1; }
.idm-thead span { line-height: 1.25; }
.idm-th-p { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.idm-th-p i { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 7px; background: #eef2f7; color: #475569; }
.idm-th-p i .idm-i { width: 14px; height: 14px; }
.idm-th-p i.idm-plus { background: var(--b); color: #fff; }
.idm-ir { padding: 12px 4px; border-bottom: 1px solid #edf1f6; }
.idm-idx { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: #dbeafe; color: var(--b-d); font-weight: 700; font-size: .85rem; }
.idm-ord { display: flex; flex-direction: column; align-items: center; color: #94a3b8; }
.idm-ord .idm-i { width: 14px; height: 14px; }
.idm-cd textarea { width: 100%; min-height: 54px; padding: 8px 10px; border: 1px solid #d5dde8; border-radius: 9px; background: #f8fafc; font: inherit; font-size: .82rem; resize: none; color: var(--ink); }
.idm-cd textarea:focus, .idm-in:focus, .idm-nt textarea:focus, .idm-pm select:focus, .idm-amt input:focus { outline: 2px solid #93c5fd; border-color: #60a5fa; }
.idm-unit { display: grid; place-items: center; min-height: 40px; border-radius: 9px; background: #eef2f7; color: #64748b; font-size: .82rem; }
.idm-in { width: 100%; height: 40px; padding: 0 8px; border: 1px solid #cbd5e1; border-radius: 9px; background: #fff; font: inherit; font-size: .9rem; text-align: center; color: var(--ink); font-variant-numeric: tabular-nums; }
.idm-tot { display: grid; place-items: center; height: 40px; border: 1px solid #86efac; border-radius: 9px; background: #ecfdf3; color: #15803d; font-weight: 800; font-variant-numeric: tabular-nums; }
.idm-vatb { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px; border: 1px solid #cbd5e1; border-radius: 9px; background: #eef2f7; font-size: .75rem; text-align: center; line-height: 1.2; }
.idm-vatb b { font-size: .8rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.idm-ia { display: flex; justify-content: flex-start; gap: 10px; margin-top: 14px; }
.idm-dr { display: flex; align-items: flex-end; gap: 12px; margin-bottom: 12px; }
.idm-dr label { flex: 1; display: block; color: #1e293b; font-weight: 600; font-size: .9rem; }
.idm-dr .idm-in { display: block; margin-top: 6px; text-align: start; padding: 0 12px; }
.idm-chipd { min-height: 34px; font-size: .8rem; margin-bottom: 4px; }
.idm-cnt { display: flex; justify-content: space-between; margin-bottom: 8px; padding: 6px 12px; border-radius: 8px; background: #f1f5f9; color: #64748b; font-size: .82rem; }
.idm-cnt b { color: var(--ok); }
.idm-tl { display: flex; align-items: baseline; gap: 8px; margin: 6px 0; font-size: 1.1rem; }
.idm-tl b { color: var(--b); font-weight: 700; font-variant-numeric: tabular-nums; }
.idm-tl.idm-g { margin-top: 10px; padding-top: 10px; border-top: 1px solid #dfe6ef; font-size: 1.25rem; }
.idm-tl.idm-g b { font-size: 1.4rem; }
.idm-taxok { margin: 10px 0; padding: 10px; border: 1px solid #4ade80; border-radius: 9px; background: #f0fdf4; color: #15803d; font-weight: 700; text-align: center; font-size: .9rem; }
.idm-payc { border: 1.5px solid #bfdbfe; }
.idm-ph { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.idm-ph h3 { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--teal); font-size: 1.3rem; font-weight: 800; }
.idm-ph span { color: var(--mut); font-size: .9rem; }
.idm-ph span b { color: var(--teal); }
.idm-paidrow { display: flex; align-items: center; gap: 10px; margin: 0; padding: 14px; border-radius: 10px; background: #f3f5f9; cursor: pointer; font-size: .92rem; position: relative; }
.idm-paidrow input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.idm-ck { display: grid; place-items: center; width: 22px; height: 22px; border: 1.5px solid #cbd5e1; border-radius: 6px; background: #fff; }
.idm-ck.on { background: #dbeafe; border-color: var(--b); color: var(--b); }
.idm-ck .idm-i { width: 14px; height: 14px; stroke-width: 3; }
.idm-paidrow:focus-within .idm-ck { outline: 3px solid #93c5fd; outline-offset: 2px; }
.idm-pm-h { display: flex; align-items: center; justify-content: space-between; margin: 14px 0 10px; color: #334155; font-weight: 600; }
.idm-pm-h span { display: inline-flex; align-items: center; gap: 8px; }
.idm-pm-h small { font-weight: 400; color: #64748b; }
.idm-pm { margin-bottom: 12px; padding: 14px; border: 1px solid #dfe6ef; border-radius: 12px; background: #f8fafc; }
.idm-pm-t { margin-bottom: 8px; font-weight: 700; font-size: .92rem; }
.idm-pm-g { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.idm-pm label, .idm-nt label, .idm-mb label { display: block; color: #334155; font-size: .8rem; font-weight: 600; }
.idm-pm label small { font-weight: 400; color: #64748b; }
.idm-pm select, .idm-mb select { display: block; width: 100%; height: 42px; margin-top: 5px; padding: 0 10px; border: 1px solid #d0d9e5; border-radius: 9px; background: #eef2f7; font: inherit; font-size: .9rem; color: var(--ink); }
.idm-amt { display: flex; align-items: center; gap: 6px; height: 42px; margin-top: 5px; padding: 0 10px; border: 1px solid #d0d9e5; border-radius: 9px; background: #eef2f7; }
.idm-amt input { flex: 1; min-width: 0; height: 100%; border: 0; background: transparent; font: inherit; font-size: .95rem; text-align: end; color: var(--ink); font-variant-numeric: tabular-nums; }
.idm-amt em { color: #64748b; font-style: normal; font-size: .85rem; }
.idm-lockrow { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 9px; background: #eff6ff; color: var(--b-d); }
.idm-lockrow b { flex: 1; font-size: .88rem; }
.idm-lockrow .idm-i { width: 20px; height: 20px; }
.idm-bal { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; padding: 12px 14px; border: 1px solid #bbf7d0; border-radius: 10px; background: #ecfdf3; color: #166534; font-size: .9rem; }
.idm-bal.warn { border-color: #fde68a; background: #fffbeb; color: #92400e; }
.idm-bal b { font-weight: 700; }
.idm-bal em { font-style: normal; font-size: .82rem; }
.idm-epay { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; padding: 10px 12px; border: 1.5px dashed #93c5fd; border-radius: 12px; background: #f5f9ff; }
.idm-epay > span { color: #334155; font-size: .85rem; font-weight: 700; }
.idm-note { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border: 1px solid #c7d7f2; border-radius: 10px; background: #eef4ff; color: #5b7bb0; font-size: .8rem; }
.idm-note .idm-i { width: 18px; height: 18px; }
.idm-nt { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.idm-nt textarea { display: block; width: 100%; margin-top: 6px; padding: 10px 12px; border: 1px solid #d0d9e5; border-radius: 10px; font: inherit; font-size: .9rem; resize: none; color: var(--ink); }
.idm-foot { position: relative; z-index: 3; display: flex; align-items: center; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line); background: #fff; }
.idm-unsaved { display: inline-flex; align-items: center; gap: 6px; color: #d97706; font-size: .8rem; font-weight: 600; }
.idm-unsaved .idm-i { width: 16px; height: 16px; }
.idm-hint { color: #94a3b8; font-size: .78rem; }
.idm-more { min-width: 40px; padding: 0 10px; cursor: default; }

/* ===== المعاينة ===== */
.idm-pvbar { display: flex; align-items: center; gap: 8px; padding: 12px 20px; background: #fff; border-bottom: 1px solid var(--line); }
.idm-pvbar > b { font-size: 1.2rem; }
.idm-pvt { color: #475569; font-size: .84rem; }
.idm-pvt u { text-decoration: none; padding: 5px 10px; border: 1px solid var(--line); border-radius: 8px; background: #f8fafc; font-weight: 700; }
.idm-ok { display: flex; align-items: center; gap: 10px; margin: 0 auto 14px; max-width: 760px; padding: 11px 16px; border: 1px solid #86efac; border-radius: 12px; background: #f0fdf4; color: #166534; font-size: .9rem; font-weight: 600; }
.idm-ok .idm-i { width: 22px; height: 22px; color: var(--ok); }
.idm-doc { max-width: 760px; margin: 0 auto 16px; padding: 26px 28px; border: 1px solid var(--line); border-radius: 6px; background: #fff; box-shadow: 0 16px 40px -22px rgba(15, 23, 42, .5); }
.idm-doc-h { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 16px; padding-bottom: 12px; border-bottom: 2px solid var(--ink); }
.idm-doc-h b { display: block; font-size: 1.15rem; }
.idm-doc-h small { color: var(--mut); }
.idm-dr2 { text-align: end; }
.idm-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.idm-party { padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; background: #f8fafc; font-size: .82rem; }
.idm-party h4 { margin: 0 0 4px; color: var(--b-d); font-size: .78rem; }
.idm-party p { margin: 2px 0; color: #334155; }
.idm-dt { width: 100%; border-collapse: collapse; font-size: .82rem; }
.idm-dt th { padding: 8px; background: #f1f5f9; border: 1px solid var(--line); text-align: start; font-size: .76rem; }
.idm-dt td { padding: 8px; border: 1px solid var(--line); }
.idm-doc-f { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-top: 16px; }
.idm-qr { text-align: center; }
.idm-qr svg { display: block; width: 96px; height: 96px; margin: 0 auto 4px; }
.idm-qr small { color: var(--mut); font-size: .7rem; }
.idm-dtot { min-width: 250px; font-size: .88rem; }
.idm-dtot > div { display: flex; justify-content: space-between; gap: 16px; padding: 5px 0; border-bottom: 1px solid #eef2f7; }
.idm-dtot .idm-gt { border-bottom: 0; padding-top: 8px; font-size: 1.05rem; font-weight: 800; color: var(--b-d); }
.idm-cta { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; max-width: 760px; margin: 0 auto; padding: 16px 20px; border-radius: 16px; background: linear-gradient(135deg, #1d4ed8, #2563eb); color: #fff; }
.idm-cta b { display: block; font-size: 1.05rem; }
.idm-cta span { display: block; margin-top: 2px; font-size: .85rem; opacity: .92; }
.idm-cta .idm-btn { background: #fff; border-color: #fff; color: var(--b-d); box-shadow: none; }

/* ===== النوافذ المنبثقة ===== */
.idm-mo { position: absolute; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; background: rgba(15, 23, 42, .5); animation: idm-fade .2s ease-out; }
.idm-md { width: min(470px, 100%); max-height: 100%; overflow: auto; border-radius: 16px; background: #fff; box-shadow: 0 30px 70px -24px rgba(0, 0, 0, .6); animation: idm-rise .25s cubic-bezier(.16, .84, .28, 1); }
.idm-mh { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid #edf1f6; }
.idm-mh b { font-size: 1.05rem; }
.idm-mb { display: grid; gap: 12px; padding: 16px 18px; }
.idm-mb input { display: block; width: 100%; height: 42px; margin-top: 5px; padding: 0 12px; border: 1px solid #c9d3e0; border-radius: 9px; font: inherit; font-size: .92rem; color: var(--ink); }
.idm-mb input:focus, .idm-mb select:focus { outline: 2px solid #93c5fd; border-color: #60a5fa; }
.idm-m2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 12px; }
.idm-err { margin: 0; color: #dc2626; font-size: .84rem; font-weight: 600; }
.idm-mf { display: flex; gap: 8px; padding: 12px 18px 16px; }
.idm-mut { margin: 0; color: #64748b; font-size: .84rem; }
.idm-c { text-align: center; }
.idm-pl-a { margin: 0; font-size: .95rem; }
.idm-pl-a b { color: var(--b-d); font-size: 1.1rem; }
.idm-pl-q { display: grid; place-items: center; padding: 10px; }
.idm-pl-q svg { width: 150px; height: 150px; padding: 8px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.idm-pl-l { display: flex; gap: 8px; }
.idm-pl-l input { margin: 0; flex: 1; direction: ltr; background: #f8fafc; font-size: .8rem; }
.idm-pl-r { display: flex; gap: 8px; justify-content: space-between; }
.idm-pl-s { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 14px; border-radius: 10px; font-size: .88rem; font-weight: 600; }
.idm-pl-s.is-wait { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.idm-pl-s.is-ok { background: #f0fdf4; color: #166534; border: 1px solid #86efac; }
.idm-pl-s .idm-btn { margin-inline-start: auto; min-height: 36px; }
.idm-pl-s .idm-i { width: 20px; height: 20px; color: var(--ok); }
.idm-spin { width: 16px; height: 16px; border: 2.5px solid #fcd34d; border-top-color: #b45309; border-radius: 50%; animation: idm-spin .9s linear infinite; }
@keyframes idm-spin { to { transform: rotate(360deg); } }
.idm-spb { justify-items: center; }
.idm-phone { position: relative; width: 168px; height: 280px; padding: 10px; border: 6px solid #0f172a; border-radius: 30px; background: #0b1b33; color: #fff; text-align: center; }
.idm-phone::before { content: ''; position: absolute; top: 6px; left: 50%; width: 46px; height: 5px; margin-left: -23px; border-radius: 9px; background: #1e293b; }
.idm-ph-scr { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; height: 100%; }
.idm-ph-scr small { color: #94a3b8; font-size: .7rem; }
.idm-ph-scr b { font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.idm-ph-scr em { font-style: normal; font-size: .78rem; color: #bfdbfe; }
.idm-nfc { display: grid; place-items: center; width: 74px; height: 74px; margin: 8px 0; border-radius: 50%; background: rgba(96, 165, 250, .16); color: #93c5fd; animation: idm-ring 2s ease-in-out infinite; }
.idm-nfc .idm-i { width: 38px; height: 38px; }
.idm-nfc.is-on { background: rgba(96, 165, 250, .35); animation-duration: .7s; }
.idm-nfc.is-ok { background: rgba(34, 197, 94, .2); color: #4ade80; animation: none; }
@keyframes idm-ring { 0%, 100% { box-shadow: 0 0 0 0 rgba(96, 165, 250, .4); } 50% { box-shadow: 0 0 0 14px rgba(96, 165, 250, 0); } }

/* ===== مرشد سالم ===== */
.idm-coach { position: absolute; left: 50%; bottom: 82px; z-index: 20; display: flex; align-items: center; gap: 12px; width: min(560px, calc(100% - 40px)); padding: 10px 16px 10px 12px; transform: translateX(-50%); border: 1px solid #c8dbf3; border-radius: 16px; background: rgba(255, 255, 255, .97); box-shadow: 0 20px 44px -18px rgba(13, 43, 78, .55); }
.idm-main.is-list .idm-coach { bottom: 16px; }
.idm-main.is-preview .idm-coach { display: none; }
.idm-coach img { flex: none; width: 54px; height: auto; }
.idm-coach-b { flex: 1; min-width: 0; }
.idm-coach-b small { display: block; color: var(--b-d); font-size: .72rem; font-weight: 800; }
.idm-coach-b b { display: block; font-size: .98rem; line-height: 1.35; }
.idm-coach-b span { display: block; color: #475569; font-size: .8rem; line-height: 1.5; }
.idm-prog { display: flex; gap: 4px; margin-top: 6px; }
.idm-prog i { flex: 1; height: 4px; border-radius: 4px; background: #dbe5f1; }
.idm-prog i.on { background: var(--b); }
.idm-toast { position: absolute; left: 50%; top: 18px; z-index: 90; padding: 10px 18px; transform: translateX(-50%); border-radius: 999px; background: #0f172a; color: #fff; font-size: .85rem; font-weight: 600; box-shadow: 0 14px 30px -12px rgba(0, 0, 0, .6); animation: idm-fade .2s ease-out; }


/* ===== نافذة «إضافة عميل جديد» (نسخة من النظام) ===== */
.idm-md.is-xl { width: min(1000px, 100%); height: 100%; max-height: 100%; display: flex; flex-direction: column; overflow: hidden; }
.idm-xh { display: flex; align-items: center; gap: 14px; padding: 16px 22px; border-bottom: 1px solid #e8edf4; background: #fff; }
.idm-xh-i { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; background: #dcfce7; color: #16a34a; flex: none; }
.idm-xh-i .idm-i { width: 24px; height: 24px; }
.idm-xh-t { flex: 1; min-width: 0; }
.idm-xh-t b { display: block; font-size: 1.45rem; font-weight: 800; line-height: 1.25; }
.idm-xh-t small { color: #64748b; font-size: .85rem; }
.idm-xh-b { display: flex; gap: 4px; }
.idm-xb { flex: 1; min-height: 0; overflow: auto; padding: 18px 22px 22px; background: #f8fafc; }
.idm-xerr { margin: 0 0 12px; padding: 10px 14px; border: 1px solid #fecaca; border-radius: 10px; background: #fef2f2; }
.idm-sec { margin-bottom: 16px; padding: 18px 20px; border: 1px solid #e5eaf1; border-radius: 14px; background: #fff; }
.idm-sec-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.idm-sec-h h4 { display: flex; align-items: center; gap: 10px; margin: 0; font-size: 1.3rem; font-weight: 800; }
.idm-sec-h h4 small { color: #64748b; font-size: .78rem; font-weight: 400; }
.idm-sec-h h4 .idm-i { width: 24px; height: 24px; }
.c-b { color: #2563eb; } .c-g { color: #16a34a; } .c-y { color: #ca8a04; } .c-o { color: #ea7c1a; }
.idm-xg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 22px; align-items: start; }
.idm-xg.idm-x2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.idm-xg .sp2 { grid-column: span 2; }
.idm-xl { display: flex; align-items: center; gap: 7px; margin-bottom: 6px; color: #0f172a; font-size: .98rem; font-weight: 700; }
.idm-xl .idm-i { width: 17px; height: 17px; color: #64748b; }
.idm-xsm { font-size: .82rem; color: #475569; font-weight: 500; }
.idm-xtitle { margin: 4px 0 8px; }
.idm-req { color: #dc2626; font-style: normal; }
.idm-opt2 { color: #64748b; font-weight: 400; font-size: .78rem; }
.idm-xi { display: block; width: 100%; height: 46px; padding: 0 14px; border: 1px solid #d3dbe6; border-radius: 9px; background: #fff; color: var(--ink); font: inherit; font-size: .95rem; }
.idm-xi::placeholder { color: #94a3b8; }
.idm-xi:focus { outline: 2px solid #93c5fd; border-color: #60a5fa; }
textarea.idm-xi { height: auto; min-height: 96px; padding: 12px 14px; resize: vertical; }
.idm-xs { -webkit-appearance: none; appearance: none; padding-inline-end: 38px; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat; background-size: 16px; background-position: right 12px center; }
[dir="rtl"] .idm-xs { background-position: left 12px center; padding-inline-end: 14px; padding-inline-start: 38px; }
.idm-xrow { display: flex; gap: 10px; align-items: center; }
.idm-xrow > .idm-xi { flex: 1; min-width: 0; }
.idm-xtag { display: grid; place-items: center; flex: none; width: 46px; height: 46px; border: 1px solid #d3dbe6; border-radius: 9px; color: #475569; }
.idm-xphone .idm-xcc { flex: 0 0 38%; }
.idm-xopen .idm-xi:last-child { flex: 0 0 38%; }
.idm-xhelp { display: block; margin-top: 5px; color: #64748b; font-size: .82rem; line-height: 1.5; }
.idm-xsub { margin: 0 0 12px; }
.idm-xvat { margin-top: 14px; }
.idm-xcnt { position: relative; }
.idm-xcnt .idm-xi { padding-inline-start: 62px; }
.idm-cnt15 { position: absolute; inset-inline-start: 8px; padding: 4px 8px; border-radius: 6px; background: #eef2f7; color: #475569; font-size: .78rem; font-style: normal; font-weight: 700; font-variant-numeric: tabular-nums; }
.idm-xmap, .idm-xmanage { display: inline-flex; align-items: center; gap: 8px; color: #1d4ed8; font-size: .88rem; font-weight: 600; }
.idm-xmanage { color: #475569; font-weight: 500; }
.idm-xmanage .idm-i { width: 16px; height: 16px; }
.idm-xdate { margin-top: 12px; max-width: 300px; }
.idm-xdate .idm-date { height: 46px; }
.idm-ph2 { color: #94a3b8; }
.idm-hr { height: 1px; margin: 16px 0; border: 0; background: #e8edf4; }
.idm-xact { min-height: 46px; width: 100%; justify-content: space-between; cursor: default; background: #fff; font-weight: 600; }
.idm-xchk { display: flex; gap: 26px; margin-bottom: 6px; }
.idm-xchk label { display: inline-flex; align-items: center; gap: 8px; font-size: .95rem; font-weight: 500; }
.idm-xdrop { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 26px 18px; border: 2px dashed #cbd5e1; border-radius: 14px; text-align: center; background: #fcfdff; }
.idm-xdrop p { margin: 0; color: #64748b; }
.idm-xdrop small { color: #94a3b8; font-size: .78rem; }
.idm-xup { color: #94a3b8; }
.idm-xup .idm-i { width: 48px; height: 48px; stroke-width: 1.5; }
.idm-xextra { display: grid; grid-template-columns: 1fr 1fr auto; gap: 12px; align-items: end; }
.idm-xaddb { min-height: 46px; opacity: .55; cursor: default; }
.idm-xnotes { margin-bottom: 4px; }
.idm-xfoot { display: flex; gap: 14px; padding: 14px 22px 18px; border-top: 1px solid #e8edf4; background: #fff; }
.idm-xfoot .idm-btn { flex: 1; min-height: 48px; font-size: 1rem; }
.idm-xfoot .idm-btn:not(.is-primary) { flex: 1; }
@media (max-width: 900px) {
    .idm-mo { padding: 0; }
    .idm-md.is-xl { width: 100%; border-radius: 0; }
    .idm-xg, .idm-xg.idm-x2 { grid-template-columns: 1fr; }
    .idm-xg .sp2 { grid-column: auto; }
    .idm-xextra { grid-template-columns: 1fr; }
    .idm-xh { padding: 12px 14px; }
    .idm-xh-t b { font-size: 1.15rem; }
    .idm-xb { padding: 12px; }
    .idm-xfoot { padding: 10px 12px; }
}

/* ===== الجوال والشاشات الضيقة ===== */
@keyframes idm-sheet { from { opacity: 0; transform: translateY(40px); } to { opacity: 1; transform: none; } }
@media (max-width: 900px) {
    .idm-root { padding: 0; }
    .idm-win { width: 100%; height: 100%; border-radius: 0; }
    .idm-side { display: none; }
    /* 16px على الأقل في الحقول: يمنع تكبير الصفحة تلقائياً في iPhone عند لمس الحقل */
    .idm-root input, .idm-root select, .idm-root textarea { font-size: 16px; }
    .idm-pm-g, .idm-nt, .idm-m2 { grid-template-columns: 1fr; }
    .idm-scroll { padding: 10px 10px 130px; }
    .idm-card { padding: 14px; border-radius: 14px; }

    /* شريط الفرع: صف واحد دائماً، والإغلاق لا ينزل لسطر وحده */
    .idm-appbar { margin: 8px 10px 0; padding: 6px 8px; gap: 8px; flex-wrap: nowrap; }
    .idm-srch, .idm-ab-i { display: none; }
    .idm-branch { min-width: 0; gap: 6px; padding: 4px; padding-inline-end: 10px; }
    .idm-branch b { flex: none; width: 28px; height: 28px; }
    .idm-branch span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .idm-branch .idm-i { display: none; }
    .idm-appbar .idm-chip { flex: none; padding: 4px 10px; font-size: .72rem; }
    .idm-close { flex: none; width: 42px; height: 42px; }

    /* عنوان الصفحة والتبويبات: أصغر، والتمرير بلا شريط ظاهر مع تلاشٍ عند الطرف */
    .idm-titlecard, .idm-tabs { margin-inline: 10px; }
    .idm-titlecard { gap: 10px; margin-top: 8px; padding: 10px 14px 6px; }
    .idm-tc-i { width: 36px; height: 36px; border-radius: 10px; }
    .idm-tc-i .idm-i { width: 20px; height: 20px; }
    .idm-titlecard h2 { font-size: 1.15rem; }
    .idm-titlecard small { font-size: .75rem; }
    .idm-tabs { overflow-x: auto; padding: 6px 8px; scrollbar-width: none; -webkit-mask-image: linear-gradient(to left, transparent 0, #000 32px); mask-image: linear-gradient(to left, transparent 0, #000 32px); }
    .idm-root[dir="ltr"] .idm-tabs { -webkit-mask-image: linear-gradient(to right, transparent 0, #000 32px); mask-image: linear-gradient(to right, transparent 0, #000 32px); }
    .idm-tabs::-webkit-scrollbar { display: none; }
    .idm-tabs span { padding: 7px 12px; font-size: .8rem; }

    /* رأس القائمة: «إضافة فاتورة» بعرض كامل، والتصدير زر أيقونة */
    .idm-filters { display: none; }
    .idm-lc-h { gap: 10px; }
    .idm-lc-t h3 { font-size: 1.2rem; }
    .idm-lc-b .idm-btn.is-primary { min-height: 46px; font-size: .95rem; }
    .idm-lc-b .is-ghost-ok { flex: none; width: 46px; min-height: 46px; padding: 0; gap: 0; font-size: 0; }
    .idm-lc-b .is-ghost-ok .idm-i:last-child { display: none; }

    /* جدول الفواتير ← بطاقات (رقم وحالة / عميل / تاريخ وإجمالي / قيود و⋯) */
    .idm-tw { overflow: visible; margin-top: 14px; border: 0; border-radius: 0; }
    .idm-lt { display: block; }
    .idm-lt thead { display: none; }
    .idm-lt tbody { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: 10px; }
    .idm-lt tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "no st" "cu cu" "dt tt" "en ac"; align-items: center; gap: 6px 12px; padding: 12px 14px; border: 1px solid #e5eaf1; border-radius: 12px; background: #fff; }
    .idm-lt td { min-width: 0; padding: 0; border: 0; white-space: normal; }
    .idm-lt td:nth-child(1) { grid-area: no; font-size: .95rem; }
    .idm-lt td:nth-child(2) { grid-area: cu; font-size: .92rem; font-weight: 600; }
    .idm-lt td:nth-child(3) { grid-area: dt; color: var(--mut); font-size: .8rem; }
    .idm-lt td:nth-child(4) { grid-area: tt; text-align: end; white-space: nowrap; }
    .idm-lt td:nth-child(5) { grid-area: st; justify-self: end; }
    .idm-lt td:nth-child(6) { grid-area: en; font-size: .82rem; }
    .idm-lt td:nth-child(7) { grid-area: ac; justify-self: end; width: auto; }
    .idm-lt tr.is-new { border-color: #bfdbfe; background: #eff6ff; animation: idm-flash 1.6s ease-out; }
    .idm-lt tr.is-new td { background: transparent; animation: none; }
    .idm-lt .idm-ibtn { width: 40px; height: 40px; border: 1px solid #e5eaf1; }
    .idm-lt .idm-ibtn.idm-pulse { border-color: #93c5fd; }
    .idm-pop { inset-inline-start: auto; inset-inline-end: 0; }

    /* مرشد سالم: الوصف ظاهر (سطران) لأن خطوة «⋯ ← رابط دفع» تُشرح فيه */
    .idm-coach { bottom: calc(76px + env(safe-area-inset-bottom)); gap: 10px; width: calc(100% - 20px); padding: 8px 12px 8px 8px; }
    .idm-main.is-list .idm-coach { bottom: calc(10px + env(safe-area-inset-bottom)); }
    .idm-coach img { width: 40px; }
    .idm-coach-b b { font-size: .92rem; }
    .idm-coach-b span { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; font-size: .74rem; line-height: 1.45; }

    /* نموذج الفاتورة */
    .idm-band { gap: 8px; padding: 12px 14px; }
    .idm-band-t { min-width: 0; }
    .idm-band-t b { font-size: 1.05rem; }
    .idm-band-t span { overflow: hidden; font-size: .74rem; text-overflow: ellipsis; white-space: nowrap; }
    .idm-band-b span.idm-bb { display: none; }
    .idm-fg { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
    .idm-fg > .idm-f:nth-child(1), .idm-fg > .idm-f:nth-child(2), .idm-fg > .idm-f:nth-child(5) { grid-column: 1 / -1; }
    .idm-lbl { font-size: .85rem; }
    .idm-date { font-size: .85rem; }
    .idm-date .idm-i { width: 18px; height: 18px; padding: 12px 9px; }
    .idm-ih { flex-wrap: wrap; gap: 10px; }
    .idm-ih h3 { font-size: 1.15rem; }
    .idm-ih .idm-btn { min-height: 34px; padding: 0 10px; font-size: .78rem; }
    .idm-thead { display: none; }
    .idm-ir { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 10px; padding: 12px; border: 1px solid #e5eaf1; border-radius: 12px; }
    .idm-ir > [data-l]::before { content: attr(data-l); display: block; margin-bottom: 3px; color: var(--teal); font-size: .72rem; font-weight: 700; }
    .idm-ir .idm-ord { display: none; }
    .idm-ir .idm-c1 { grid-column: 1; grid-row: 1; }
    .idm-ir .idm-c1::before { display: none; }
    .idm-ir .idm-cx { grid-column: 3; grid-row: 1; justify-self: end; }
    .idm-ir .idm-cx .idm-ibtn { width: 40px; height: 40px; }
    .idm-ir .idm-cp, .idm-ir .idm-cd { grid-column: 1 / -1; }
    .idm-ir .idm-ct { grid-column: span 2; }
    .idm-in { padding: 0 6px; }
    .idm-dr { flex-wrap: wrap; }
    .idm-tl { font-size: 1rem; }
    .idm-tl.idm-g { font-size: 1.1rem; }
    .idm-tl.idm-g b { font-size: 1.25rem; }
    .idm-ph { flex-direction: column; align-items: flex-start; gap: 4px; }
    .idm-ph h3 { font-size: 1.15rem; }
    .idm-pm-h { flex-wrap: wrap; gap: 8px; }
    .idm-pm-h .idm-btn { min-height: 36px; padding: 0 12px; font-size: .82rem; }
    .idm-bal { flex-direction: column; align-items: flex-start; gap: 4px; }
    .idm-epay > span, .idm-epay .idm-btn { flex: 1 1 100%; }
    .idm-note { align-items: flex-start; }
    .idm-foot { flex-wrap: nowrap; gap: 8px; padding: 10px; padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
    .idm-unsaved, .idm-hint, .idm-more, .idm-foot .idm-sp { display: none; }
    .idm-foot .idm-btn { flex: 1; min-width: 0; min-height: 44px; padding: 0 8px; }
    .idm-foot .idm-btn.is-primary { flex: 1.4; }

    /* المعاينة */
    .idm-parties { grid-template-columns: 1fr; }
    .idm-doc { padding: 16px; }
    .idm-doc-f { flex-direction: column; align-items: stretch; }
    .idm-dtot { min-width: 0; order: -1; }
    .idm-pvbar { flex-wrap: wrap; }
    .idm-pvt { display: none; }
    .idm-pvbar .idm-btn { flex: 1; min-width: 0; padding: 0 8px; }

    /* النوافذ: لوح سفلي على الجوال */
    .idm-mo { place-items: end center; }
    .idm-md { width: 100%; max-height: 92%; padding-bottom: env(safe-area-inset-bottom); border-radius: 18px 18px 0 0; animation: idm-sheet .28s cubic-bezier(.16, .84, .28, 1); }
    .idm-md.is-xl { max-height: 100%; padding-bottom: 0; }
    .idm-mf .idm-btn, .idm-pl-r .idm-btn { flex: 1; min-height: 44px; }
    .idm-xfoot { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
    .idm-xh-b span.idm-bb, .idm-xh-t small { display: none; }
}
@media (max-width: 640px) {
    .idm-lc-b { width: 100%; }
    .idm-lc-b .idm-btn.is-primary { flex: 1; }
    /* شريط المعاينة: العنوان والإغلاق في صف، ثم طباعة / PDF / واتساب بأعمدة متساوية */
    .idm-pvbar { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding: 10px; }
    .idm-pvbar > b { grid-column: 1 / 3; grid-row: 1; align-self: center; font-size: 1.05rem; }
    .idm-pvbar > .idm-sp { display: none; }
    .idm-pvbar > [data-act="tolist"] { grid-column: 3; grid-row: 1; justify-self: end; min-height: 36px; padding: 0 14px; }
    .idm-pvbar .idm-btn { min-height: 42px; padding: 0 6px; gap: 6px; font-size: .8rem; }
    .idm-pvbar .idm-btn .idm-i { width: 15px; height: 15px; }
    .idm-ok { align-items: flex-start; padding: 10px 12px; font-size: .82rem; }
    .idm-doc { padding: 14px; }
    .idm-doc-h b { font-size: 1rem; }
    /* أسطر الفاتورة: الصنف ثم الكمية والسعر والضريبة والإجمالي بعناوين صغيرة، بلا تمرير أفقي */
    .idm-dt { display: block; font-size: .8rem; }
    .idm-dt thead { display: none; }
    .idm-dt tbody { display: block; border-top: 1px solid var(--line); }
    .idm-dt tr { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
    .idm-dt td { padding: 0; border: 0; }
    .idm-dt td:nth-child(1), .idm-dt td:nth-child(3) { display: none; }
    .idm-dt td:nth-child(2) { grid-column: 1 / -1; font-weight: 700; }
    .idm-dt td[data-l]::before { content: attr(data-l); display: block; color: var(--mut); font-size: .7rem; font-weight: 600; }
    .idm-dt td:nth-child(7) { font-weight: 800; text-align: end; }
    .idm-qr { margin-top: 4px; }
    .idm-cta { padding: 14px 16px; }
    .idm-cta .idm-btn { width: 100%; min-height: 46px; }
}
@media (prefers-reduced-motion: reduce) {
    .idm-root *, .idm-root *::before, .idm-root *::after { animation: none !important; transition: none !important; }
}
