/* نسخة الجوال: نفس روح تطبيق التصاريح والمخالفات — هيدر داكن، بطاقات بشريط لون، شريط سفلي */
body.m {
  --bg: #f4f2ee; --card: #ffffff; --surface: #ffffff; --ink: #1d2430; --ink-2: #5f6878; --ink-3: #848c99; --muted: #5f6878; --line: #dcd8cf;
  --brand: #0d0d0f; --brand-2: #2b2b31; --brand-sub: #b9b6ad; --brand-line: #3a3a40; --accent: #e3a01b;
  --ok: #1d7a4a; --ok-soft: #dcefe4; --warn: #a86108; --warn-soft: #f6e7cf; --bad: #b23a2e; --bad-soft: #f5dcd8; --info: #1f5f8b; --info-soft: #dbe9f3; --neutral-soft: #e9e6df;
  --good: var(--ok); --good-bg: var(--ok-soft); --bad-bg: var(--bad-soft); --warn-bg: var(--warn-soft);
  --tabs-h: 62px; --safe-b: env(safe-area-inset-bottom, 0px);
  background: var(--bg); color: var(--ink); font-family: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, "Noto Sans Arabic", "Geeza Pro", sans-serif;
  -webkit-tap-highlight-color: transparent; overscroll-behavior-y: contain;
  padding-bottom: calc(var(--tabs-h) + var(--safe-b));
}
.m-app { max-width: 760px; margin: 0 auto; }
.m-top { background: var(--brand); color: #fff; border-radius: 0 0 18px 18px; padding: calc(14px + env(safe-area-inset-top, 0px)) 16px 14px; }
.m-brand { display: flex; align-items: center; gap: 12px; }
.m-brand img { width: 42px; height: 42px; border-radius: 10px; flex: none; }
.m-titles { min-width: 0; }
.m-top h1 { margin: 0; font-size: 1.35rem; line-height: 1.25; }
.m-sub { color: var(--brand-sub); font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-bell { margin-inline-start: auto; position: relative; width: 42px; height: 42px; display: grid; place-items: center; color: #fff; border: 1px solid var(--brand-line); border-radius: 12px; flex: none; }
.m-bell svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.m-bell .badge { position: absolute; top: -6px; inset-inline-end: -6px; margin: 0; }
.m-site { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.m-site span { color: var(--brand-sub); font-size: .8rem; flex: none; }
.m-site select { flex: 1; min-width: 0; font: inherit; font-size: .92rem; padding: 9px 10px; border-radius: 10px; border: 1px solid var(--brand-line); background: #1c1c20; color: #fff; }

.m-main { padding: 0 14px 24px; }
.m-main.m-has-actions { padding-bottom: 90px; }
.m-loading { text-align: center; color: var(--muted); padding: 40px 0; }

/* الأرقام */
.m-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 12px 0 2px; }
@media (min-width: 520px) { .m-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.m-stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 9px 12px; text-align: start; font: inherit; color: inherit; cursor: pointer; min-width: 0; }
.m-stat b { display: block; font-size: 1.3rem; font-variant-numeric: tabular-nums; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-stat span { color: var(--muted); font-size: .76rem; }
.m-stat.s-bad b { color: var(--bad); } .m-stat.s-warn b { color: var(--warn); } .m-stat.s-ok b { color: var(--ok); }
.m-stat.on { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }

/* البحث والفلاتر */
.m-band { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 10px 0 8px; margin: 0 -14px; padding-inline: 14px; border-bottom: 1px solid var(--line); }
.m-search input { width: 100%; font: inherit; font-size: 1rem; padding: 11px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.m-search input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.m-chips { display: flex; gap: 6px; overflow-x: auto; padding-top: 8px; scrollbar-width: none; }
.m-chips::-webkit-scrollbar { display: none; }
body.m .chip { flex: none; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 999px; padding: 6px 12px; font: inherit; font-size: .82rem; cursor: pointer; white-space: nowrap; }
body.m .chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
body.m .chip i { font-style: normal; color: var(--muted); margin-inline-start: 5px; font-variant-numeric: tabular-nums; }
body.m .chip[aria-pressed="true"] i { color: inherit; opacity: .75; }
.m-count { color: var(--muted); font-size: .82rem; padding: 10px 2px 6px; }

/* البطاقات */
.m-list { display: grid; gap: 10px; }
.m-card { display: grid; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-inline-start: 5px solid var(--line); border-radius: 14px;
  padding: 12px 14px; color: inherit; text-decoration: none; min-width: 0; transition: transform .08s; }
.m-card:active { transform: scale(.985); background: #faf9f6; }
.k-bad { border-inline-start-color: var(--bad) !important; } .k-warn { border-inline-start-color: var(--warn) !important; }
.k-ok { border-inline-start-color: var(--ok) !important; } .k-info { border-inline-start-color: var(--info) !important; }
.row1 { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.pn { font-weight: 700; font-size: 1.05rem; direction: ltr; unicode-bidi: isolate; font-variant-numeric: tabular-nums; }
.pn.big { font-size: 1.3rem; }
body.m .pill { font-size: .78rem; font-weight: 600; border-radius: 7px; padding: 2px 9px; white-space: nowrap; }
.p-ok { background: var(--ok-soft); color: var(--ok); } .p-bad { background: var(--bad-soft); color: var(--bad); } .p-warn { background: var(--warn-soft); color: var(--warn); }
.p-info { background: var(--info-soft); color: var(--info); } .p-n { background: var(--neutral-soft); color: var(--muted); }
body.m .pill.good { background: var(--ok-soft); color: var(--ok); } body.m .pill.bad { background: var(--bad-soft); color: var(--bad); } body.m .pill.warn { background: var(--warn-soft); color: var(--warn); }
.pjt { font-weight: 600; font-size: .92rem; }
.meta { color: var(--muted); font-size: .84rem; display: flex; flex-wrap: wrap; gap: 2px 14px; }
.meta b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.hint { font-size: .84rem; color: var(--bad); font-weight: 600; } .hint.w { color: var(--warn); } .hint.i { color: var(--muted); font-weight: 500; }
.days { font-weight: 700; font-size: .9rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.days.bad { color: var(--bad); } .days.warn { color: var(--warn); } .days.ok { color: var(--ok); }
.m-mini { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .78rem; }
.m-bar { display: inline-block; width: 64px; height: 6px; background: #e7e3da; border-radius: 3px; overflow: hidden; vertical-align: middle; }
.m-bar i { display: block; height: 100%; background: var(--ok); }
.m-bar.big { display: block; width: 100%; height: 8px; margin: 2px 0 8px; }
.m-more-btn { display: block; margin: 6px auto 0; }
body.m .empty { text-align: center; color: var(--muted); padding: 34px 10px; }

/* زر الإضافة */
.m-fab { position: fixed; z-index: 8; bottom: calc(var(--tabs-h) + var(--safe-b) + 14px); inset-inline-start: max(16px, calc(50% - 364px));
  width: 58px; height: 58px; border-radius: 18px; border: 0; background: var(--accent); color: #141210; font-size: 32px; line-height: 1; font-weight: 400;
  box-shadow: 0 8px 22px rgba(0,0,0,.22); cursor: pointer; }

/* الشريط السفلي */
.m-tabs { position: fixed; z-index: 9; inset: auto 0 0 0; height: calc(var(--tabs-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: var(--surface); border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(var(--n), 1fr); }
.m-tabs a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); text-decoration: none; font-size: .72rem; font-weight: 600; position: relative; }
.m-tabs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.m-tabs a.on { color: var(--ink); }
.m-tabs a.on::before { content: ""; position: absolute; top: 0; width: 34px; height: 3px; border-radius: 0 0 3px 3px; background: var(--accent); }

/* شاشة التفاصيل */
.m-subbar { display: flex; justify-content: space-between; align-items: center; padding: 12px 0 8px; }
.m-back { color: var(--ink); text-decoration: none; font-weight: 600; padding: 6px 2px; }
.m-share { font: inherit; font-size: .88rem; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 6px 14px; cursor: pointer; color: var(--ink); }
.m-hero { background: var(--surface); border: 1px solid var(--line); border-inline-start: 6px solid var(--line); border-radius: 16px; padding: 14px 16px; display: grid; gap: 6px; }
.m-amount { color: var(--muted); }
.m-amount b { font-size: 1.9rem; color: var(--ink); font-variant-numeric: tabular-nums; margin-inline-end: 4px; }
.m-amount b.bad { color: var(--bad); } .m-amount b.warn { color: var(--warn); } .m-amount b.ok { color: var(--ok); }
.m-amount s { font-size: .9rem; margin-inline-start: 6px; }
.m-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; margin: 6px 0 0; padding-top: 10px; border-top: 1px solid var(--line); }
.m-facts dt { font-size: .75rem; color: var(--muted); } .m-facts dd { margin: 0; font-weight: 600; font-size: .9rem; word-break: break-word; }
.m-facts a { color: var(--info); }
.m-desc { white-space: pre-wrap; margin: 4px 0 0; font-size: .9rem; color: var(--ink-2); }
.m-sec { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; margin-top: 12px; }
.m-sec-h { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.m-sec h2 { margin: 0; font-size: 1.05rem; }
.m-prog { font-weight: 700; color: var(--warn); } .m-prog.full { color: var(--ok); }
.m-tip { color: var(--muted); font-size: .8rem; margin: 0 0 6px; }

/* التشييك: أزرار كبيرة للإصبع */
.m-checks { list-style: none; margin: 0; padding: 0; }
.m-checks li { display: flex; align-items: center; gap: 4px; border-bottom: 1px solid var(--line); }
.m-checks li:last-child { border-bottom: 0; }
.m-check { flex: 1; display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 8px 0; background: none; border: 0; font: inherit; color: inherit; text-align: start; cursor: pointer; }
.m-check i { flex: none; width: 30px; height: 30px; border-radius: 50%; border: 2px solid #c9c3b6; display: grid; place-items: center; transition: .15s; }
.m-check.on i { background: var(--ok); border-color: var(--ok); }
.m-check.on i::after { content: ""; width: 8px; height: 14px; border: solid #fff; border-width: 0 3px 3px 0; transform: rotate(45deg) translate(-1px, -1px); }
.m-check span { display: grid; font-weight: 600; }
.m-check small { font-weight: 400; color: var(--warn); font-size: .76rem; }
.m-check.on small { color: var(--ok); }
.m-check.on span { color: var(--ink-2); }
.m-check:disabled { cursor: default; }
.m-x { background: none; border: 0; color: var(--bad); font-size: 22px; padding: 8px 10px; cursor: pointer; }
.m-addreq { display: flex; gap: 8px; margin-top: 10px; }
.m-addreq input { flex: 1; min-width: 0; font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; }

/* الصور */
.m-photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 4px 0 10px; }
.m-photos:empty { display: none; }
.m-ph { aspect-ratio: 1; border: 0; border-radius: 10px; background: #e7e3da center / cover no-repeat; position: relative; padding: 0; cursor: zoom-in; display: block; }
.m-ph small { position: absolute; inset: auto 0 0 0; background: linear-gradient(transparent, rgba(0,0,0,.55)); color: #fff; font-size: .68rem; padding: 10px 6px 3px; border-radius: 0 0 10px 10px; text-align: start; }
.m-photo-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.m-up { font-size: .82rem; margin-top: 6px; }
.m-up:empty { display: none; }

/* الأزرار الكبيرة وشريط الإجراء */
.m-btn { display: flex; align-items: center; justify-content: center; min-height: 50px; padding: 0 16px; border-radius: 14px; border: 1px solid transparent;
  font: inherit; font-weight: 700; font-size: 1rem; cursor: pointer; text-align: center; }
.m-btn.ok { background: var(--ok); color: #fff; } .m-btn.dark { background: var(--ink); color: #fff; }
.m-btn.ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
.m-btn:active { filter: brightness(.92); }
.m-actions { position: fixed; z-index: 8; inset-inline: 0; bottom: calc(var(--tabs-h) + var(--safe-b)); padding: 10px 14px; background: rgba(244,242,238,.94);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-top: 1px solid var(--line); display: flex; gap: 8px; max-width: 760px; margin: 0 auto; }
.m-actions:empty { display: none; }
.m-actions .m-btn { flex: 1; } .m-actions .m-btn.narrow { flex: 0 0 auto; }
.m-done-note { flex: 1; text-align: center; color: var(--ok); font-weight: 700; padding: 12px; background: var(--ok-soft); border-radius: 14px; }

/* الأقسام القابلة للطي */
.m-fold { padding: 0; }
.m-fold > summary { list-style: none; cursor: pointer; padding: 14px 16px; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.m-fold > summary::-webkit-details-marker { display: none; }
.m-fold > summary::after { content: "⌄"; margin-inline-start: auto; color: var(--muted); transition: .15s; }
.m-fold[open] > summary::after { transform: rotate(180deg); }
.m-fold > :not(summary) { padding: 0 16px 14px; }
.m-fold .card { border: 0; padding: 0; background: none; }
.m-fold .card.pad { padding: 0; } .m-fold .card h2 { font-size: .95rem; }
.m-sec .card.pad { border: 0; padding: 0; } .m-sec .card.pad > h2 { font-size: 1.05rem; }
.m-sec .upload-bar { display: grid; grid-template-columns: 1fr 1fr; } .m-sec .upload-bar .kind-select { grid-column: 1 / -1; }
.m-sec .upload-bar .btn { text-align: center; padding: 11px; }
.m-sec .gallery { grid-template-columns: repeat(3, 1fr); gap: 6px; }

/* الحالة */
.m-status-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.m-st { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 6px; cursor: pointer; }
.m-st .pill { font-size: .9rem; }
.m-st.on { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }

/* النوافذ تصير لوحة من تحت */
body.m dialog { width: 100%; max-width: 760px; margin: auto auto 0; border-radius: 20px 20px 0 0; max-height: 92vh; padding-bottom: var(--safe-b); }
body.m dialog .dlg-body { max-height: calc(92vh - 140px); }
body.m dialog .dlg-foot .btn { flex: 1; padding: 12px; font-size: 1rem; border-radius: 12px; }
body.m dialog .field input, body.m dialog .field select, body.m dialog textarea { font-size: 16px; padding: 11px 12px; border-radius: 10px; }
body.m dialog .m-photos { margin-top: 8px; }
body.m dialog .m-photo-pick .m-btn { min-height: 46px; font-size: .92rem; }
body.m #toast { bottom: calc(var(--tabs-h) + var(--safe-b) + 76px); max-width: calc(100vw - 32px); text-align: center; }

/* عارض الصور */
.m-viewer { position: fixed; inset: 0; z-index: 50; background: #000; display: grid; place-items: center; }
.m-viewer img { max-width: 100%; max-height: 100%; object-fit: contain; }
.m-v-bar { position: absolute; top: env(safe-area-inset-top, 0px); inset-inline: 0; display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; color: #fff; }
.m-v-bar button { background: rgba(255,255,255,.15); border: 0; color: #fff; font-size: 26px; width: 44px; height: 44px; border-radius: 50%; cursor: pointer; }

/* اسحب للتحديث */
.m-ptr { position: fixed; top: calc(10px + env(safe-area-inset-top, 0px)); left: 50%; transform: translate(-50%, -70px); z-index: 30; background: var(--ink); color: #fff;
  padding: 6px 16px; border-radius: 999px; font-size: .82rem; transition: transform .15s; pointer-events: none; }
.m-ptr.on { transform: translate(-50%, 0); }

/* المزيد */
.m-me { margin-top: 14px; } .m-me b { font-size: 1.15rem; } .m-me span { color: var(--muted); font-size: .88rem; }
.m-menu { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; margin-top: 12px; overflow: hidden; }
.m-menu a, .m-menu button { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 54px; padding: 0 16px; border: 0; border-bottom: 1px solid var(--line);
  background: none; font: inherit; font-weight: 600; color: var(--ink); text-decoration: none; text-align: start; cursor: pointer; }
.m-menu > :last-child { border-bottom: 0; }
.m-menu i { margin-inline-start: auto; font-style: normal; color: var(--muted); font-size: 1.3rem; }
[dir="ltr"] .m-menu i { transform: scaleX(-1); }
.m-menu .badge { margin-inline-start: 8px; }
.m-menu .danger { color: var(--bad); }
.m-ver { text-align: center; font-size: .78rem; margin-top: 18px; }

/* الصفحات الثانية داخل نسخة الجوال */
.m-legacy { padding-top: 14px; }
.m-legacy .head h1 { font-size: 1.25rem; }
.m-legacy .stats { grid-template-columns: 1fr 1fr; gap: 8px; }
.m-legacy .stat { padding: 10px 12px; } .m-legacy .stat .n { font-size: 1.3rem; }
.m-legacy .grid2 { grid-template-columns: 1fr; }
.m-legacy .row2 { grid-template-columns: 1fr; }
.m-legacy table.rows thead { display: none; }
.m-legacy table.rows, .m-legacy table.rows tbody, .m-legacy table.rows tr, .m-legacy table.rows td { display: block; width: 100%; }
.m-legacy table.rows tr { border-bottom: 1px solid var(--line); padding: 10px 14px; }
.m-legacy table.rows td { border: 0; padding: 3px 0; display: flex; justify-content: space-between; gap: 12px; white-space: normal; max-width: none; min-width: 0; }
.m-legacy table.rows td::before { content: attr(data-label); color: var(--ink-3); font-size: 13px; }
.m-legacy .filter-form, .m-legacy .filter-form input, .m-legacy .filter-form select { width: 100%; min-width: 0; max-width: none; }
.m-legacy .filter-form { flex-direction: column; }
.m-legacy .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
body.m .card { border-radius: 14px; }
body.m dialog .btn.m-ok { background: var(--ok); }

/* على شاشة الكمبيوتر: الشريط السفلي بنفس عرض المحتوى */
.m-tabs { max-width: 760px; margin: 0 auto; }
@media (min-width: 761px) { .m-tabs { border-inline: 1px solid var(--line); border-radius: 14px 14px 0 0; } }

/* بدون اتصال (0.14) */
.m-off { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 999px; background: #f5b335; color: #1a1300; font-weight: 700; font-size: .82rem; text-decoration: none; margin-inline-start: auto; margin-inline-end: 8px; }
.m-off.bad { background: #e5322d; color: #fff; }
.m-off[hidden] { display: none; }
.m-outbox { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.m-outbox li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.m-outbox li.bad { border-color: #e5322d; }
.m-outbox li div { display: flex; flex-direction: column; gap: 2px; }
.m-outbox small { color: var(--muted); }
.m-hero .m-btn { margin-top: 10px; }
.m-off:not([hidden]) + .m-bell { margin-inline-start: 0; }
