/* الخطوط مستضافة مع السيستم (رخصة OFL في fonts/) عشان الـ CSP وعشان تشتغل من غير إنترنت */
@font-face{font-family:Cairo;font-style:normal;font-weight:400;font-display:swap;src:url(/fonts/cairo-arabic-400-normal.woff2) format('woff2');unicode-range:U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC}
@font-face{font-family:Cairo;font-style:normal;font-weight:400;font-display:swap;src:url(/fonts/cairo-latin-400-normal.woff2) format('woff2');unicode-range:U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD}
@font-face{font-family:Cairo;font-style:normal;font-weight:600;font-display:swap;src:url(/fonts/cairo-arabic-600-normal.woff2) format('woff2');unicode-range:U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC}
@font-face{font-family:Cairo;font-style:normal;font-weight:600;font-display:swap;src:url(/fonts/cairo-latin-600-normal.woff2) format('woff2');unicode-range:U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD}
@font-face{font-family:Cairo;font-style:normal;font-weight:700;font-display:swap;src:url(/fonts/cairo-arabic-700-normal.woff2) format('woff2');unicode-range:U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC}
@font-face{font-family:Cairo;font-style:normal;font-weight:700;font-display:swap;src:url(/fonts/cairo-latin-700-normal.woff2) format('woff2');unicode-range:U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD}
@font-face{font-family:Inter;font-style:normal;font-weight:500;font-display:swap;src:url(/fonts/inter-latin-500-normal.woff2) format('woff2');unicode-range:U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD}
@font-face{font-family:Inter;font-style:normal;font-weight:700;font-display:swap;src:url(/fonts/inter-latin-700-normal.woff2) format('woff2');unicode-range:U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD}
/* هوية دمج: فحمي #09090B وبرتقالي #F27405. Cairo للنصوص و Inter للأرقام. RTL.
   الأزرار البرتقالي نصها غامق (التباين 6.9:1)، والأبيض على البرتقالي ممنوع (2.9:1). */
:root {
  --nav: #09090B; --tile: #1C1C20; --tileB: #2A2A2F; --navMuted: #A1A1AA;
  --brand: #F27405; --brandHover: #FF8A1F; --brandSoft: #FBD3B0; --onBrand: #09090B;
  --ink: #14171C; --muted: #5B6670; --line: #E4E4E7; --bg: #FAFAFA; --card: #fff;
  --warn: #9A3412; --warn-bg: #FFF1E6; --warn-b: #FBD3B0; --bad: #B91C1C; --bad-bg: #FDECEC; --ok: #15803D; --ok-bg: #E7F6EC;
  --font: Cairo, "Segoe UI", Tahoma, system-ui, sans-serif; --num: Inter, Cairo, "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); color: var(--ink); background: var(--bg); font-size: 15px; }
.num, td.money, th.money, .kpi b { font-family: var(--num); font-variant-numeric: tabular-nums; }
td.money, th.money, .kpi b { white-space: nowrap; }
a { color: #C2410C; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; border: 0; border-radius: 10px; padding: 9px 16px; background: var(--brand); color: var(--onBrand); font-weight: 700; min-height: 40px; }
button:hover { background: var(--brandHover); }
button.ghost { background: #fff; color: var(--ink); border: 1px solid #D4D4D8; font-weight: 600; }
button.ghost:hover { border-color: var(--brand); background: #fff; }
button.danger { background: var(--bad); color: #fff; }
button:disabled { opacity: .5; cursor: default; }
button:focus-visible, a:focus-visible, .tile:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
input, select, textarea { width: 100%; padding: 9px 12px; border: 1px solid #D4D4D8; border-radius: 10px; background: #fff; color: var(--ink); min-height: 42px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); border-color: var(--brand); }
label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
label.check { display: flex; align-items: center; gap: 8px; color: var(--ink); }
label.check input { width: 18px; height: 18px; min-height: 0; accent-color: var(--brand); }

/* ===== الهيكل: قائمة المربعات تلت الشاشة، والباقي للمحتوى ===== */
.shell { display: flex; flex-wrap: wrap; min-height: 100vh; }
.shell.bare { display: block; }
nav.side { flex: 1 1 340px; max-width: 33.333%; min-width: 300px; background: var(--nav); color: #fff; display: flex; flex-direction: column; height: 100vh; position: sticky; top: 0; }
nav.side .top { padding: 20px 20px 10px; display: flex; flex-direction: column; gap: 12px; }
nav.side .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; flex-wrap: wrap; }
.logo { display: inline-flex; align-items: center; gap: 6px; font-family: Inter, sans-serif; letter-spacing: 1px; }
.sep { width: 1px; height: 20px; background: rgba(255,255,255,.25); }
.flag { font-size: 12px; background: rgba(255,255,255,.12); padding: 3px 10px; border-radius: 99px; font-weight: 600; }
nav.side label { color: var(--navMuted); }
nav.side input { background: var(--tile); color: #fff; border-color: var(--tileB); }
.tiles { flex: 1; overflow-y: auto; padding: 4px 20px 24px; display: flex; flex-direction: column; gap: 12px; scrollbar-color: #3f3f46 transparent; }
.tiles .group { font-size: 12px; color: var(--navMuted); font-weight: 700; margin-top: 4px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.tile { aspect-ratio: 1; border-radius: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; font-size: 13px; font-weight: 600; text-align: center; padding: 6px; line-height: 1.3;
  background: var(--tile); color: #fff; border: 2px solid var(--tileB); transition: transform .12s, border-color .12s; min-height: 0; }
.tile:hover { background: var(--tile); border-color: var(--brand); transform: translateY(-2px); }
.tile.on, .tile.on:hover { background: #fff; color: var(--nav); border-color: #fff; box-shadow: inset 0 -4px 0 var(--brand); }
.tile .badge { font-family: var(--num); font-size: 12px; background: var(--brand); color: var(--onBrand); border-radius: 99px; padding: 0 8px; }
.tile .count { font-family: var(--num); font-size: 12px; opacity: .75; }
.navfoot { padding: 10px 20px 16px; border-top: 1px solid var(--tileB); display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--navMuted); font-size: 13px; }
.navfoot button { background: transparent; color: var(--navMuted); border: 1px solid var(--tileB); min-height: 36px; padding: 6px 12px; font-weight: 600; }
.navfoot button:hover { color: #fff; border-color: var(--brand); background: transparent; }
main { flex: 999 1 560px; min-width: 0; padding: 26px 30px; }

h1 { font-size: 23px; margin: 0 0 16px; }
h2 { font-size: 16px; margin: 0 0 12px; }
.head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 16px; }
.head h1 { margin: 0; }
.head > div:first-child { flex: 1 1 260px; }
.head p { margin: 4px 0 0; }
.bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: 14px; }
.bar > label { min-width: 160px; }
.spacer { flex: 1; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin-bottom: 16px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.cards .card { margin-bottom: 0; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); margin-bottom: 16px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; text-align: start; color: var(--ink); font-weight: 400; display: flex; flex-direction: column; gap: 2px; min-height: 0; }
button.kpi:hover { background: #fff; border-color: var(--brand); }
.kpi span { color: var(--muted); font-size: 13px; display: block; }
.kpi b { font-size: 24px; }
.kpi small { color: var(--muted); font-size: 12px; }
.kpi.warnk { background: var(--warn-bg); border-color: var(--warn-b); }
.kpi.warnk span, .kpi.warnk b, .kpi.warnk small { color: var(--warn); }
.bars { display: flex; align-items: flex-end; gap: 10px; height: 150px; border-bottom: 1px solid var(--line); margin-top: 22px; }
.bars div { flex: 1; background: var(--brandSoft); border-radius: 6px 6px 0 0; position: relative; min-height: 2px; }
.bars div.last { background: var(--brand); }
.bars em { position: absolute; top: -18px; inset-inline: 0; text-align: center; font-style: normal; font-size: 11px; color: var(--muted); font-family: var(--num); }
.barlbl { display: flex; gap: 10px; margin-top: 6px; } .barlbl span { flex: 1; text-align: center; font-size: 12px; color: var(--muted); font-family: var(--num); }
.ringrow { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.ring { width: 120px; height: 120px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.ring div { width: 88px; height: 88px; border-radius: 50%; background: #fff; display: flex; align-items: center; justify-content: center; font-family: var(--num); font-weight: 700; font-size: 22px; }
.rlist { flex: 1 1 140px; display: flex; flex-direction: column; gap: 8px; } .rlist div { display: flex; justify-content: space-between; } .rlist b { font-family: var(--num); }
.alerts { display: flex; flex-direction: column; gap: 8px; }
.alerts button { text-align: start; font-weight: 400; background: #F4F4F5; color: var(--ink); }
.alerts button.w { background: var(--warn-bg); color: var(--warn); }
.alerts button:hover { outline: 2px solid var(--brandSoft); }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { text-align: start; padding: 9px 10px; border-bottom: 1px solid #F0F0F2; vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: #FAFAFA; position: sticky; top: 0; white-space: nowrap; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #FFF7F0; }
.tablewrap { overflow: auto; border: 1px solid var(--line); border-radius: 14px; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 12px; background: #F4F4F5; white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); } .pill.warn { background: var(--warn-bg); color: var(--warn); } .pill.bad { background: var(--bad-bg); color: var(--bad); }
.alert { background: var(--warn-bg); color: var(--warn); padding: 10px 14px; border-radius: 10px; margin-bottom: 12px; }
.error { color: var(--bad); min-height: 1.2em; font-size: 13px; }
.muted { color: var(--muted); }
.toast { pointer-events: none; z-index: 30; position: fixed; bottom: 20px; inset-inline-end: 20px; background: var(--nav); color: #fff; padding: 12px 18px; border-radius: 12px; border-inline-start: 4px solid var(--brand); opacity: 0; transform: translateY(10px); transition: .2s; max-width: 90vw; }
.toast.show { opacity: 1; transform: none; }
dialog { border: 0; border-radius: 16px; padding: 0; width: min(720px, 94vw); }
dialog::backdrop { background: rgba(9, 9, 11, .55); }
dialog .head { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; margin: 0; }
dialog .body { padding: 18px; display: grid; gap: 12px; max-height: 70vh; overflow: auto; }
dialog .foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }
.meter { height: 12px; background: #E4E4E7; border-radius: 99px; overflow: hidden; margin: 10px 0; } .meter div { height: 100%; background: var(--brand); }

/* صفحة الاشتراك والدخول */
.signup { max-width: 860px; margin: 40px auto; padding: 0 16px; }
.brandbar { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; margin-bottom: 18px; }
.countries { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 18px 0; }
.country { border: 2px solid var(--line); border-radius: 16px; padding: 18px; background: #fff; text-align: start; color: var(--ink); font-weight: 400; }
.country:hover { background: #fff; border-color: var(--brandSoft); }
.country.on { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(242,116,5,.15); }
.country h3 { margin: 0 0 6px; font-size: 20px; }
.country ul { margin: 8px 0 0; padding-inline-start: 18px; color: var(--muted); font-size: 13px; line-height: 1.8; }

@media (max-width: 900px) {
  nav.side { max-width: none; height: auto; position: static; flex-basis: 100%; }
  .tiles { max-height: 340px; }
  .grid3 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  main { padding: 16px; }
  .countries { grid-template-columns: 1fr; }
}
@media (max-width: 480px) { .tile { font-size: 12px; } }

/* ===== المساعد الذكي: الشخصية والشات ===== */
.ai-fab { position: fixed; bottom: 18px; inset-inline-end: 18px; z-index: 40; display: flex; align-items: center; gap: 8px; background: #fff; color: var(--ink); border: 2px solid var(--nav); border-radius: 99px; padding: 4px 14px 4px 4px; box-shadow: 0 6px 24px rgba(9,9,11,.18); font-weight: 700; }
.ai-fab:hover, .ai-fab.on { background: #fff; border-color: var(--brand); }
.ai-panel { position: fixed; bottom: 84px; inset-inline-end: 18px; z-index: 40; width: min(400px, calc(100vw - 24px)); height: min(600px, calc(100vh - 110px)); background: #fff; border-radius: 18px; box-shadow: 0 16px 48px rgba(9,9,11,.28); display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--line); }
.ai-panel[hidden] { display: none; }
.ai-panel header { background: var(--nav); color: #fff; display: flex; align-items: center; gap: 10px; padding: 10px 12px; }
.ai-panel header small { display: block; color: var(--navMuted); font-size: 12px; }
.ai-ico { background: transparent; color: var(--navMuted); border: 1px solid var(--tileB); min-height: 32px; padding: 4px 10px; font-size: 12px; font-weight: 600; }
.ai-ico:hover { background: transparent; color: #fff; border-color: var(--brand); }
.ai-log { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; background: var(--bg); }
.ai-msg { max-width: 85%; padding: 9px 12px; border-radius: 14px; white-space: pre-wrap; line-height: 1.6; font-size: 14px; }
.ai-msg.user { align-self: flex-start; background: var(--nav); color: #fff; border-start-start-radius: 4px; }
.ai-msg.assistant { align-self: flex-end; background: #fff; border: 1px solid var(--line); border-start-end-radius: 4px; }
.ai-msg.error { align-self: center; background: var(--bad-bg); color: var(--bad); }
.ai-tool { align-self: flex-end; color: var(--muted); font-size: 12px; }
.ai-confirm { margin: 0 12px 8px; padding: 10px 12px; border: 2px solid var(--brand); border-radius: 12px; background: var(--warn-bg); }
.ai-confirm pre { margin: 6px 0; white-space: pre-wrap; font-size: 12px; direction: ltr; text-align: left; max-height: 120px; overflow: auto; }
#aiForm { display: flex; gap: 6px; padding: 10px; border-top: 1px solid var(--line); align-items: flex-end; }
#aiForm textarea { resize: none; min-height: 42px; max-height: 120px; }
.ai-mic { background: #fff; color: var(--ink); border: 1px solid #D4D4D8; padding: 8px 10px; }
.ai-mic.rec { background: var(--bad); color: #fff; border-color: var(--bad); }
.ai-av { display: block; border-radius: 50%; object-fit: cover; background: #C9C1BE; }
.ai-panel header .ai-av { box-shadow: 0 0 0 2px var(--brand); }
.ai-hero { align-self: center; height: auto; margin: 4px 0 2px; border-radius: 16px; background: #C9C1BE; }
.ai-dot { position: absolute; top: 2px; inset-inline-start: 38px; width: 10px; height: 10px; border-radius: 50%; background: #F7A800; border: 2px solid #fff; }
.ai-dot[hidden] { display: none; }
/* سيا (جوه أنظمة سبيل): ألوان tokens.json في ريبو SIA، والأيقونة 56 على الويب و52 على الموبايل، بعيد 24 عن الحافة */
#ai-root.sia .ai-fab { bottom: 24px; inset-inline-end: 24px; border-color: #00B4A6; }
#ai-root.sia .ai-fab:hover, #ai-root.sia .ai-fab.on { border-color: #2EC27E; }
#ai-root.sia .ai-fab .ai-av { width: 48px; height: 48px; }
#ai-root.sia .ai-av { background: #F4F8FA; }
#ai-root.sia .ai-panel header .ai-av { box-shadow: 0 0 0 2px #00B4A6; }
#ai-root.sia .ai-hero { background: #F5FCF9; }
#ai-root.sia .ai-panel { bottom: 92px; inset-inline-end: 24px; }
#ai-root.sia .ai-face.thinking .ai-av { animation: sia-think 1.2s ease-in-out infinite; }
@keyframes sia-think { 50% { box-shadow: 0 0 0 4px #F7A800; } }
.ai-bubble { position: fixed; bottom: 92px; inset-inline-end: 24px; z-index: 40; max-width: 260px; background: #fff; border: 1px solid #00B4A6; border-radius: 14px; padding: 10px 14px; box-shadow: 0 8px 24px rgba(9,9,11,.16); cursor: pointer; font-size: 14px; line-height: 1.6; }
.ai-bubble[hidden] { display: none; }
@media (prefers-reduced-motion: reduce) { #ai-root.sia .ai-face.thinking .ai-av { animation: none; } }
@media (max-width: 480px) { #ai-root.sia .ai-fab .ai-av { width: 44px; height: 44px; } }
@media (max-width: 480px) { .ai-fab span { display: none; } .ai-fab { padding: 4px; } }
.ai-fields { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; margin: 8px 0; font-size: 14px; }
.ai-fields dt { color: var(--warn); } .ai-fields dd { margin: 0; font-weight: 600; }
.cam-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.cam-card { border: 1px solid var(--line, #E4E4E7); border-radius: 12px; overflow: hidden; background: #fff; }
.cam-shot { aspect-ratio: 4 / 3; background: #18181B; color: #A1A1AA; display: grid; place-items: center; font-size: 13px; }
.cam-shot img { width: 100%; height: 100%; object-fit: cover; }
.cam-meta { padding: 10px; display: grid; gap: 4px; font-size: 13px; } .cam-meta span { color: var(--muted, #71717A); }
.cam-meta select { margin-top: 4px; } .cam-meta .bar { margin-top: 6px; }
