:root {
  --brand: #014fa2; --brand-2: #0a6ad6; --brand-soft: #e8f0fb;
  --ink: #17202c; --muted: #5d6a7a; --line: #dfe5ec; --bg: #f4f6f9; --card: #ffffff;
  --green: #1e9e5a; --green-soft: #e3f5ea; --orange: #e58a00; --orange-soft: #fff1dc; --red: #d23a3a; --red-soft: #fde6e6;
  --yellow: #f2c200; --radius: 12px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  font-size: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font-family: "Segoe UI", Tahoma, "Noto Sans Arabic", "Noto Sans", Arial, sans-serif; line-height: 1.45; -webkit-tap-highlight-color: transparent; }
[dir=ltr] body { font-family: "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif; }
a { color: var(--brand); text-decoration: none; }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.25; }
h1 { font-size: 1.35rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
.boot { padding: 3rem; text-align: center; color: var(--muted); }

/* الإطار */
.top { position: sticky; top: 0; z-index: 20; background: var(--brand); color: #fff; display: flex; align-items: center; gap: .6rem; padding: .55rem .9rem; padding-top: max(.55rem, env(safe-area-inset-top)); }
.top .logo { height: 30px; background: #fff; border-radius: 6px; padding: 2px 6px; }
.top .title { font-weight: 700; flex: 1; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top button, .top select { background: rgba(255,255,255,.14); color: #fff; border: 0; border-radius: 8px; padding: .4rem .6rem; font: inherit; font-size: .85rem; cursor: pointer; }
.top select option { color: var(--ink); }
.top .back { font-weight: 700; padding: .45rem .8rem; background: rgba(255,255,255,.22); white-space: nowrap; }
.net { width: 9px; height: 9px; border-radius: 50%; background: #5be38f; display: inline-block; }
.net.off { background: #ff8a8a; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 1rem; padding-bottom: 5rem; }
.crumb { color: var(--muted); font-size: .85rem; margin-bottom: .6rem; }
.crumb a { color: var(--muted); }

/* البطاقات والشبكة */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; margin-bottom: 1rem; }
.card h2 { display: flex; align-items: center; gap: .5rem; }
.grid { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.grid.tiles { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.tile { display: flex; flex-direction: column; gap: .3rem; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); color: var(--ink); min-height: 96px; cursor: pointer; }
.tile:hover { border-color: var(--brand-2); }
.tile .ic { font-size: 1.6rem; }
.tile b { font-size: .98rem; }
.tile small { color: var(--muted); font-size: .8rem; }
.kpis { display: grid; gap: .6rem; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: .7rem .8rem; }
.kpi .v { font-size: 1.5rem; font-weight: 700; }
.kpi .l { font-size: .8rem; color: var(--muted); }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: .6rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.sep { border: 0; border-top: 1px solid var(--line); margin: 1rem 0; }
.right { margin-inline-start: auto; }

/* الأزرار والحقول */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 10px; padding: .6rem 1rem; font: inherit; font-weight: 600; cursor: pointer; min-height: 44px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.ok { background: var(--green); border-color: var(--green); color: #fff; }
.btn.warn { background: var(--orange); border-color: var(--orange); color: #fff; }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.ghost { background: transparent; }
.btn.sm { min-height: 34px; padding: .3rem .7rem; font-size: .85rem; border-radius: 8px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
label.f { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .2rem; }
input, select, textarea { font: inherit; border: 1px solid var(--line); border-radius: 10px; padding: .55rem .7rem; background: #fff; color: var(--ink); width: 100%; min-height: 44px; }
textarea { min-height: 80px; }
input[type=checkbox] { width: 20px; height: 20px; min-height: 0; }
.fields { display: grid; gap: .7rem; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.seg button { border: 0; background: transparent; padding: .45rem .8rem; font: inherit; cursor: pointer; min-height: 40px; }
.seg button + button { border-inline-start: 1px solid var(--line); }
.seg button.on { background: var(--brand); color: #fff; }

/* الشارات والألوان */
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .12rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600; background: #eef1f5; color: var(--muted); white-space: nowrap; }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.orange { background: var(--orange-soft); color: #a86400; }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.blue { background: var(--brand-soft); color: var(--brand); }
.dot { width: 14px; height: 14px; border-radius: 50%; display: inline-block; background: #c9d1db; vertical-align: middle; }
.dot.green { background: var(--green); } .dot.orange { background: var(--orange); } .dot.red { background: var(--red); }
.bar { height: 8px; background: #e9edf2; border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--green); }

/* الجداول */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.t { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.t th, table.t td { padding: .5rem .55rem; border-bottom: 1px solid var(--line); text-align: start; vertical-align: middle; }
table.t th { font-size: .78rem; color: var(--muted); font-weight: 600; background: #f8fafc; position: sticky; top: 0; }
table.t tr.over td { background: var(--red-soft); }
table.t tr:hover td { background: #fafcff; }
code, .mono { font-family: Consolas, "SFMono-Regular", Menlo, monospace; font-size: .85em; direction: ltr; unicode-bidi: embed; }

/* المسح */
.scan-box { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; aspect-ratio: 4/3; max-height: 60vh; margin: 0 auto; }
.scan-box video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-box .frame { position: absolute; inset: 18%; border: 3px solid rgba(255,255,255,.85); border-radius: 14px; box-shadow: 0 0 0 999px rgba(0,0,0,.35); }
.scan-box .hint { position: absolute; bottom: .6rem; inset-inline: 0; text-align: center; color: #fff; font-weight: 600; text-shadow: 0 1px 3px #000; }
.scan-steps { display: flex; gap: .4rem; margin: .7rem 0; }
.scan-steps span { flex: 1; text-align: center; padding: .45rem; border-radius: 8px; background: #eef1f5; font-size: .85rem; color: var(--muted); }
.scan-steps span.on { background: var(--brand); color: #fff; }
.scan-steps span.done { background: var(--green-soft); color: var(--green); }
.result { border-radius: var(--radius); padding: 1rem; font-size: 1.05rem; font-weight: 600; text-align: center; margin: .7rem 0; }
.result.ok { background: var(--green-soft); color: var(--green); }
.result.err { background: var(--red-soft); color: var(--red); }
.result.info { background: var(--brand-soft); color: var(--brand); }
.testpick { border: 2px dashed var(--orange); border-radius: var(--radius); padding: .7rem; background: var(--orange-soft); }

/* التفتيش */
.chk-row { border: 1px solid var(--line); border-radius: 10px; padding: .7rem; margin-bottom: .6rem; background: #fff; }
.chk-row.v-OK { border-inline-start: 6px solid var(--green); }
.chk-row.v-HALF { border-inline-start: 6px solid var(--orange); }
.chk-row.v-X { border-inline-start: 6px solid var(--red); }
.chk-row.excl { opacity: .6; }
.pts { display: flex; flex-wrap: wrap; gap: .35rem; margin: .5rem 0; }
.pt { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: .35rem .6rem; font-size: .85rem; cursor: pointer; min-height: 38px; }
.pt.crit { border-color: #f3b56b; background: #fff8ee; }
.pt.fail { background: var(--red); border-color: var(--red); color: #fff; }
.verdict { font-size: 1.2rem; font-weight: 700; min-width: 2.4rem; text-align: center; }
.verdict.OK { color: var(--green); } .verdict.HALF { color: var(--orange); } .verdict.X { color: var(--red); }
.result-box { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; padding: 1rem; border-radius: var(--radius); background: #f8fafc; border: 1px solid var(--line); }
.result-box .score { font-size: 2rem; font-weight: 800; }
.sticky-foot { position: sticky; bottom: 0; background: rgba(244,246,249,.96); padding: .6rem 0; border-top: 1px solid var(--line); z-index: 5; }

/* F-01-B */
.slots { display: flex; flex-wrap: wrap; gap: 3px; }
.slot { width: 34px; font-size: .62rem; text-align: center; padding: 2px 0; border-radius: 4px; background: #eef1f5; color: var(--muted); direction: ltr; }
.slot.done { background: var(--green); color: #fff; }
.slot.miss { background: var(--red-soft); color: var(--red); }

/* الطباعة: الشارات والملصقات */
.labels { display: grid; grid-template-columns: repeat(auto-fill, minmax(62mm, 1fr)); gap: 4mm; }
.label { border: 1px dashed #9aa6b5; border-radius: 8px; padding: 3mm; display: flex; gap: 3mm; align-items: center; background: #fff; break-inside: avoid; }
.label img.qr { width: 26mm; height: 26mm; image-rendering: pixelated; }
.label .txt { font-size: 9pt; line-height: 1.3; }
.label .txt b { font-size: 10pt; display: block; }
.label .brand { height: 7mm; }
@media print {
  .top, .noprint, #toast, .crumb { display: none !important; }
  .wrap { padding: 0; max-width: none; }
  body, html { background: #fff; }
  .card { border: 0; box-shadow: none; padding: 0; }
}

#toast { position: fixed; bottom: 1rem; inset-inline: 1rem; z-index: 100; display: flex; flex-direction: column; gap: .4rem; align-items: center; pointer-events: none; }
#toast div { background: var(--ink); color: #fff; padding: .6rem 1rem; border-radius: 10px; box-shadow: var(--shadow); max-width: 520px; pointer-events: auto; }
#toast div.err { background: var(--red); }
#toast div.ok { background: var(--green); }
.modal-bg { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; padding: 1rem; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 640px; max-height: 90vh; overflow: auto; padding: 1rem; }
@media (min-width: 700px) { .modal-bg { align-items: center; } }
.login { max-width: 380px; margin: 8vh auto; }
.login .logo-big { display: block; width: 220px; margin: 0 auto 1rem; }
.demo-accounts { font-size: .82rem; }
.demo-accounts button { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: .3rem .5rem; margin: .15rem; cursor: pointer; font: inherit; font-size: .8rem; }
.empty { text-align: center; color: var(--muted); padding: 1.5rem; }
.pill-test { background: var(--orange); color: #fff; border-radius: 6px; padding: 0 .4rem; font-size: .72rem; }
h2.grp { margin: 1.4rem 0 .5rem; font-size: 1.05rem; color: var(--brand); }
.btn.big { min-height: 56px; font-size: 1.1rem; }
a.kpi { color: inherit; text-decoration: none; display: block; }
