/* «المساح»: كحلي وأبيض وذهبي (من الشعار). الهاتف أولاً: أزرار 48 بكسل على الأقل، أرقام كبيرة، وتباين عالي للشمس */
:root {
  --navy: #123a7a; --pri: #123a7a; --pri-d: #0b2a5b; --pri2: #1d5fbf; --acc: #f2b01e; --acc-d: #9a6700;
  --ink2: #1f2d4d; --green: #157347; --purple: #5b3ea6;
  --tint-b: #f3f7fd; --tint-p: #f7f5fd; --tint-g: #e8f5ee; --chip: #e7eefb;
  --bg: #f4f7fb; --card: #ffffff; --line: #e1e7f0; --line2: #c9d3e1;
  --tx: #0f1d33; --mut: #4f5d74; --mut2: #64748b;
  --ok: #15803d; --ok-bg: #dcfce7; --warn: #b45309; --warn-bg: #fef3c7; --bad: #b91c1c; --bad-bg: #fee2e2;
  --gps: #0284c7; --link: #1d5fbf;
  --r: 14px; --sh: 0 1px 2px rgb(15 23 42 / .06), 0 6px 20px rgb(15 23 42 / .08);
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a1222; --card: #111b2e; --line: #1e2b42; --line2: #33435e; --tx: #e3e9f3; --mut: #9aa9c0; --mut2: #94a3b8;
    --ok-bg: #052e16; --warn-bg: #3b2a06; --bad-bg: #3b0d0d; --link: #8bb8ff; --pri: #1d4d9a; --navy: #9cc0ff; --pri2: #8bb8ff; --ink2: #dbe5f4;
    --green: #5fd39a; --purple: #b9a6f2; --tint-b: #0f1b31; --tint-p: #15132a; --tint-g: #0d2418; --chip: #1a2a47; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0a1222; --card: #111b2e; --line: #1e2b42; --line2: #33435e; --tx: #e3e9f3; --mut: #9aa9c0; --mut2: #94a3b8;
  --ok-bg: #052e16; --warn-bg: #3b2a06; --bad-bg: #3b0d0d; --link: #8bb8ff; --pri: #1d4d9a; --navy: #9cc0ff; --pri2: #8bb8ff; --ink2: #dbe5f4;
  --green: #5fd39a; --purple: #b9a6f2; --tint-b: #0f1b31; --tint-p: #15132a; --tint-g: #0d2418; --chip: #1a2a47; color-scheme: dark;
}
/* وضع الشمس: أسود على أبيض وخطوط أعرض (بالميدان تحت الشمس) */
:root[data-sun="1"] { --bg: #fff; --card: #fff; --line: #0f172a; --line2: #0f172a; --tx: #000; --mut: #111; --mut2: #222; color-scheme: light; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--tx); font: 16px/1.55 'IBM Plex Sans Arabic', system-ui, 'Segoe UI', Tahoma, sans-serif; }
a { color: var(--link); }
h1, h2, h3 { line-height: 1.3; margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
.num, .ltr { direction: ltr; unicode-bidi: isolate; font-variant-numeric: tabular-nums; }
.mut { color: var(--mut); }
.small { font-size: 13px; }
.hide { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--acc); outline-offset: 2px; }

/* ---------- عناصر عامة ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 18px; border-radius: 12px;
  border: 1px solid var(--line2); background: var(--card); color: var(--tx); font-weight: 600; text-decoration: none; cursor: pointer; touch-action: manipulation; }
.btn.pri { background: var(--pri); border-color: var(--pri); color: #fff; }
.btn.acc { background: var(--acc); border-color: var(--acc); color: #1c1917; }
.btn.bad { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.sm { min-height: 40px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.btn svg { width: 20px; height: 20px; flex: none; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 14px; color: var(--mut); font-weight: 600; }
.field .hint { font-size: 12.5px; color: var(--mut2); }
.field .err { font-size: 13px; color: var(--bad); }
.in { min-height: 48px; width: 100%; padding: 0 12px; border: 1px solid var(--line2); border-radius: 12px; background: var(--card); font-size: 16px; }
textarea.in { padding: 10px 12px; min-height: 90px; }
.in.ltr { text-align: right; }
.in[aria-invalid="true"] { border-color: var(--bad); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; min-height: 28px; border-radius: 99px; font-size: 13px; font-weight: 600;
  background: var(--line); color: var(--tx); white-space: nowrap; }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.chip.gps { background: #e0f2fe; color: #075985; }
.notice { border-radius: var(--r); padding: 14px 16px; border: 1px solid; }
.notice.warn { background: var(--warn-bg); border-color: #f59e0b; color: var(--tx); }
.notice.ok { background: var(--ok-bg); border-color: #22c55e; }
.notice.bad { background: var(--bad-bg); border-color: #ef4444; }
.notice b { display: block; margin-bottom: 4px; }
.check { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; cursor: pointer; }
.check input { width: 24px; height: 24px; margin: 2px 0 0; flex: none; accent-color: var(--pri); }
.toast { position: fixed; inset-inline: 16px; bottom: calc(90px + var(--safe-b)); z-index: 2000; margin: auto; max-width: 480px; padding: 12px 16px;
  border-radius: 12px; background: #0f172a; color: #fff; font-weight: 600; text-align: center; box-shadow: var(--sh); }

/* ---------- الصفحات العادية (الدخول، البطاقة، المدير، التحقق) ---------- */
.top { display: flex; align-items: center; gap: 10px; padding: calc(10px + var(--safe-t)) 16px 10px; background: var(--pri-d); color: #fff; }
.top a { color: #fff; text-decoration: none; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }
.brand svg { width: 34px; height: 34px; flex: none; }
.top .sp { flex: 1; }
.top .who { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.top .who img { width: 32px; height: 32px; border-radius: 50%; }
.page { max-width: 720px; margin: 0 auto; padding: 16px 16px calc(32px + var(--safe-b)); display: flex; flex-direction: column; gap: 16px; }
.page h1 { font-size: 24px; }
.page h2 { font-size: 18px; }
.foot { text-align: center; font-size: 13px; color: var(--mut); padding: 8px 16px 24px; }
.foot a { color: inherit; }
.feat { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.feat li { display: flex; gap: 12px; align-items: flex-start; }
.feat li svg { width: 28px; height: 28px; flex: none; color: var(--pri); }
:root[data-theme="dark"] .feat li svg { color: var(--acc); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .feat li svg { color: var(--acc); } }

/* صورة البطاقة */
.ph { display: flex; gap: 14px; align-items: center; }
.ph .pic { width: 96px; height: 120px; border-radius: 12px; background: var(--line); object-fit: cover; flex: none; display: grid; place-items: center; color: var(--mut); overflow: hidden; }
.ph .pic img { width: 100%; height: 100%; object-fit: cover; }
.status { display: flex; gap: 12px; align-items: center; }

/* بطاقة التحقق العامة */
.idcard { max-width: 420px; margin: 0 auto; width: 100%; border-radius: 18px; overflow: hidden; background: var(--card); border: 1px solid var(--line); box-shadow: var(--sh); }
.idcard .hd { background: var(--pri-d); color: #fff; padding: 14px 16px; display: flex; align-items: center; gap: 10px; }
.idcard .bd { padding: 18px 16px; display: grid; gap: 12px; justify-items: center; text-align: center; }
.idcard .bd img.face { width: 132px; height: 164px; border-radius: 12px; object-fit: cover; background: var(--line); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; width: 100%; text-align: start; }
.kv dt { color: var(--mut); font-size: 14px; }
.kv dd { margin: 0; font-weight: 600; }

/* المدير */
.adm { display: grid; gap: 12px; }
.adm .c { display: grid; grid-template-columns: 84px 1fr; gap: 12px; }
.adm .c > a { display: block; width: 84px; height: 104px; overflow: hidden; border-radius: 10px; font-size: 11px; }
.adm .c img { width: 84px; height: 104px; object-fit: cover; border-radius: 10px; background: var(--line); }
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.tabs button { flex: none; min-height: 40px; padding: 0 14px; border-radius: 99px; border: 1px solid var(--line2); background: var(--card); font-weight: 600; }
.tabs button[aria-pressed="true"] { background: var(--pri); border-color: var(--pri); color: #fff; }

/* ---------- تطبيق الميدان ---------- */
.fx { position: fixed; inset: 0; display: flex; flex-direction: column; }
.fx .bar { position: relative; z-index: 600; display: flex; align-items: center; gap: 8px; padding: calc(6px + var(--safe-t)) 10px 6px; background: var(--pri-d); color: #fff; min-height: 52px; }
.fx .bar .brand svg { width: 34px; height: 34px; background: #fff; border-radius: 10px; padding: 2px; }
.fx .bar .ttl { flex: 1; min-width: 0; font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fx .bar .ttl small { display: block; font-weight: 400; font-size: 12px; opacity: .85; }
.fx .bar .ib { width: 44px; height: 44px; border-radius: 10px; border: 0; background: rgb(255 255 255 / .1); color: #fff; display: grid; place-items: center; }
.fx .bar .ib svg { width: 22px; height: 22px; }
.fx .bar a.ib { text-decoration: none; }
#map { flex: 1; min-height: 0; background: #dfe7ef; direction: ltr; }
.leaflet-bottom { bottom: 14px; }
.leaflet-container { font: 13px 'IBM Plex Sans Arabic', system-ui, sans-serif; }
/* أزرار فوق الخريطة */
.fab { position: absolute; z-index: 500; inset-inline-start: 10px; display: flex; flex-direction: column; gap: 8px; }
.fab button { width: 48px; height: 48px; border-radius: 12px; border: 1px solid var(--line2); background: var(--card); color: var(--tx); box-shadow: var(--sh); display: grid; place-items: center; }
.fab button svg { width: 24px; height: 24px; }
.fab button[aria-pressed="true"] { background: var(--gps); border-color: var(--gps); color: #fff; }
.gpsbadge { position: absolute; z-index: 500; inset-inline-end: 10px; top: 62px; }

/* اللوحة السفلية: ثلاث درجات (مطوية، نص، كاملة) بالسحب أو بالكبس */
.sheet { position: relative; z-index: 550; background: var(--card); border-radius: 18px 18px 0 0; box-shadow: 0 -6px 24px rgb(15 23 42 / .14);
  display: flex; flex-direction: column; max-height: 46vh; transition: max-height .2s ease; margin-top: -14px; }
.sheet[data-size="min"] { max-height: 132px; }
.sheet[data-size="max"] { max-height: 82vh; }
.sheet .grip { flex: none; height: 26px; display: grid; place-items: center; cursor: grab; touch-action: none; border: 0; background: none; width: 100%; }
.sheet .grip::before { content: ''; width: 44px; height: 5px; border-radius: 3px; background: var(--line2); }
.sheet .body { overflow-y: auto; overscroll-behavior: contain; padding: 0 14px 14px; display: flex; flex-direction: column; gap: 12px; }
/* اللوحة بتنسحب، فالعناصر ما بتنضغط (جدول الزوايا كان ينطوي لصفر) */
.sheet .body > * { flex-shrink: 0; }
.nav { flex: none; display: grid; grid-template-columns: repeat(4, 1fr); background: var(--card); border-top: 1px solid var(--line); padding-bottom: var(--safe-b); position: relative; z-index: 560; }
.nav button { min-height: 58px; border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 12.5px; font-weight: 600; color: var(--mut); }
.nav button svg { width: 24px; height: 24px; }
.nav button[aria-current="page"] { color: var(--pri); }
:root[data-theme="dark"] .nav button[aria-current="page"] { color: var(--acc); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .nav button[aria-current="page"] { color: var(--acc); } }

/* البحث */
.srch { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.srch .town { grid-column: 1 / -1; position: relative; }
.sugg { position: absolute; inset-inline: 0; top: 100%; z-index: 10; margin: 4px 0 0; padding: 4px; list-style: none; background: var(--card); border: 1px solid var(--line2); border-radius: 12px; box-shadow: var(--sh); max-height: 240px; overflow-y: auto; }
.sugg li button { width: 100%; min-height: 44px; text-align: start; border: 0; background: none; padding: 6px 10px; border-radius: 8px; }
.sugg li button:hover, .sugg li button:focus { background: var(--bg); }
.sugg small { color: var(--mut); }
.recent { display: flex; gap: 8px; overflow-x: auto; }
.recent button { flex: none; }

/* أرقام كبيرة للميدان */
.big { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.big > div { background: var(--bg); border-radius: 12px; padding: 8px 10px; }
.big span { display: block; font-size: 12.5px; color: var(--mut); }
.big b { display: block; font-size: 24px; direction: ltr; text-align: right; font-variant-numeric: tabular-nums; letter-spacing: .3px; }
.big .full { grid-column: 1 / -1; }
.stat { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.stat:last-child { border-bottom: 0; }
.stat b { font-variant-numeric: tabular-nums; }

/* التوقيع (الوصول للزاوية) */
.stake { display: grid; grid-template-columns: 140px 1fr; gap: 12px; align-items: center; }
.arrow { width: 140px; height: 140px; border-radius: 50%; background: var(--bg); display: grid; place-items: center; position: relative; }
.arrow svg { width: 112px; height: 112px; transition: transform .25s linear; }
.arrow.near { background: var(--ok-bg); }
.arrow .n { position: absolute; top: 4px; left: 0; right: 0; text-align: center; transform-origin: 50% 66px; font-size: 12px; font-weight: 700; color: var(--bad); }
.dist { font-size: 40px; font-weight: 700; direction: ltr; text-align: right; font-variant-numeric: tabular-nums; line-height: 1.1; }
.vchips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.vchips button { flex: none; min-width: 44px; min-height: 44px; border-radius: 10px; border: 1px solid var(--line2); background: var(--card); font-weight: 700; }
.vchips button[aria-pressed="true"] { background: var(--pri); border-color: var(--pri); color: #fff; }

/* جدول الزوايا */
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: start; white-space: nowrap; }
@media (max-width: 420px) { .tbl { font-size: 13px; } .tbl th, .tbl td { padding: 7px 4px; } }
.tbl th { font-size: 12.5px; color: var(--mut); font-weight: 600; position: sticky; top: 0; background: var(--card); }
.tbl td.num { text-align: right; }
.tbl tr[aria-selected="true"] td { background: #fef9c3; }
:root[data-theme="dark"] .tbl tr[aria-selected="true"] td { background: #3b3206; }
.tblw { overflow-x: auto; }
.src { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.src button { min-height: 52px; border-radius: 12px; border: 1px solid var(--line2); background: var(--card); text-align: start; padding: 6px 10px; line-height: 1.3; }
.src button small { display: block; color: var(--mut); font-size: 12px; }
.src button[aria-pressed="true"] { border: 2px solid var(--pri); background: #f0f9ff; }
:root[data-theme="dark"] .src button[aria-pressed="true"] { background: #0c2a3d; border-color: var(--acc); }

/* أرقام الزوايا على الخريطة */
.vlbl { background: #0c4a6e; color: #fff; border: 2px solid #fff; border-radius: 50%; width: 26px !important; height: 26px !important; margin: -13px 0 0 -13px !important;
  display: grid; place-items: center; font: 700 12px/1 'IBM Plex Sans Arabic', sans-serif; box-shadow: 0 1px 4px rgb(0 0 0 / .4); }
.vlbl.on { background: var(--acc); color: #1c1917; }
.nlbl { background: none; border: 0; color: #fff; font: 600 12px/1 'IBM Plex Sans Arabic', sans-serif; text-shadow: 0 0 3px #000, 0 0 3px #000; white-space: nowrap; }
.mylbl { width: 18px !important; height: 18px !important; margin: -9px 0 0 -9px !important; border-radius: 50%; background: var(--gps); border: 3px solid #fff; box-shadow: 0 0 0 2px rgb(2 132 199 / .4); }

/* أهداف من المكتب على الخريطة */
.vlbl.cadv { background: #1d4ed8; }
.vlbl.cadv.on { background: var(--acc); color: #1c1917; }

/* شاشة التوقيع الكاملة: سهم كبير ومسافة كبيرة، تنقرا تحت الشمس وبإيد وحدة */
.sfs { position: fixed; inset: 0; z-index: 2500; background: var(--card); color: var(--tx); display: grid; grid-template-rows: auto 1fr auto auto;
  padding: calc(8px + var(--safe-t)) 14px calc(12px + var(--safe-b)); gap: 8px; }
.sfs.near { background: var(--ok-bg); }
.sfs-top { display: flex; align-items: center; gap: 10px; }
.sfs-x { width: 48px; height: 48px; border-radius: 12px; border: 1px solid var(--line2); background: var(--card); font-size: 22px; }
.sfs-t { flex: 1; font-weight: 700; font-size: 18px; }
.sfs-mid { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center; min-height: 0; }
.sfs-arrow { width: min(62vw, 300px); aspect-ratio: 1; border-radius: 50%; background: var(--bg); display: grid; place-items: center; position: relative; color: var(--pri); }
.sfs-arrow > span:last-child { width: 78%; height: 78%; display: grid; transition: transform .25s linear; }
.sfs-arrow svg { width: 100%; height: 100%; }
.sfs-arrow .n { position: absolute; top: 6px; left: 0; right: 0; text-align: center; transform-origin: 50% calc(min(31vw, 150px) - 6px); font-weight: 700; color: var(--bad); }
.sfs.near .sfs-arrow { color: var(--ok); }
.sfs-d { font-size: clamp(44px, 14vw, 80px); font-weight: 700; direction: ltr; font-variant-numeric: tabular-nums; line-height: 1; }
.sfs-g { font-size: 20px; font-weight: 700; }
.sfs-e { font-size: 15px; color: var(--mut); }
.sfs-bot { display: grid; grid-template-columns: 1fr 1.4fr 1fr; gap: 8px; }
.sfs-bot .btn { min-height: 56px; }
.sfs-note { font-size: 13px; color: var(--mut); text-align: center; min-height: 1.2em; }

/* الجولة التعليمية */
.tour { position: fixed; inset: 0; z-index: 4000; }
.tour[hidden] { display: none; }
.tour-hole { position: fixed; border-radius: 12px; box-shadow: 0 0 0 9999px rgb(8 30 46 / .64); outline: 3px solid var(--acc); transition: all .25s ease; pointer-events: none; }
.tour-card { position: fixed; max-height: calc(100dvh - 20px); overflow-y: auto; background: var(--card); color: var(--tx); border-radius: 16px; padding: 14px 16px 10px; border-top: 5px solid var(--acc); box-shadow: 0 12px 40px rgb(0 0 0 / .35); transition: top .25s ease, left .25s ease; }
.tour-k { font-size: 12.5px; font-weight: 700; color: var(--acc-d); }
.tour-card h2 { margin: 2px 0 6px; font-size: 18px; color: var(--pri); }
:root[data-theme="dark"] .tour-card h2 { color: var(--acc); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tour-card h2 { color: var(--acc); } }
.tour-card p { margin: 0 0 10px; line-height: 1.8; font-size: 15px; }
.tour-try { margin-bottom: 8px; }
.tour-try:empty { display: none; }
.tour-dots { display: flex; gap: 4px; justify-content: center; margin-bottom: 6px; flex-wrap: wrap; }
.tour-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--line2); }
.tour-dots i.on { background: var(--acc-d); width: 18px; border-radius: 4px; }
.tour-nav { display: flex; align-items: center; gap: 6px; }
.tour-nav span { flex: 1; }
.tour-skip { background: none; border: 0; color: var(--mut); font-weight: 600; min-height: 40px; padding: 0 6px; }

/* الطباعة: المخطط بس */
@media print {
  body * { visibility: hidden; }
  #print, #print * { visibility: visible; }
  #print { position: absolute; inset: 0; }
}
#print { display: none; }
@media print { #print { display: block; } }

/* بطاقة التنظيم بالميدان */
.zc { padding: 12px; display: grid; gap: 8px; }
.zchips { display: flex; flex-wrap: wrap; gap: 6px; }
.zchip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 99px; padding: 3px 10px; font-size: 13.5px; font-weight: 600; }
.zchip i { width: 12px; height: 12px; border-radius: 3px; border: 1px solid #0004; }
.zobj { color: #be185d; margin: 0; font-weight: 600; }

/* صفحة النظام */
.page.law { max-width: 860px; padding-inline: 20px; }
.law .lawq { padding: 12px; display: grid; gap: 8px; }
@media (min-width: 1001px) { .law .lawq { position: sticky; top: 77px; z-index: 5; } .law section, .law article { scroll-margin-top: 150px; } }
.lawk { display: flex; flex-wrap: wrap; gap: 6px; }
.lawk a { font-size: 13px; font-weight: 600; border: 1px solid var(--line); border-radius: 99px; padding: 2px 10px; text-decoration: none; }
.law .art h2 { font-size: 17px; margin: 0 0 6px; }
.law .art h2 a { text-decoration: none; }
.law .art h2 span { color: var(--mut); font-weight: 600; }
.lawx p { margin: 0 0 6px; line-height: 1.9; }
.lawx p.sub { padding-inline-start: 18px; }
.law .tbl th { white-space: normal; }
.law :target { outline: 3px solid var(--acc); }
