:root { --bg: #060a14; --gold: #f2c14e; --ink: #e9eefb; --mut: #8b97b5; --line: rgba(255, 255, 255, .09); }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink); font-family: "Segoe UI", "Noto Kufi Arabic", Tahoma, sans-serif; }
button, input { font: inherit; color: inherit; }

#bg { position: fixed; inset: 0; background: radial-gradient(1200px 720px at 50% 46%, #14244a 0%, #0a1226 46%, #060a14 100%); }
#bg::after { content: ""; position: absolute; inset: 0; background-image: radial-gradient(rgba(255, 255, 255, .08) 1px, transparent 1px); background-size: 34px 34px; -webkit-mask-image: radial-gradient(ellipse at center, #000 25%, transparent 78%); mask-image: radial-gradient(ellipse at center, #000 25%, transparent 78%); }

.vp { position: fixed; inset: 0; overflow: hidden; cursor: grab; touch-action: none; user-select: none; }
.vp:active { cursor: grabbing; }
.world { position: absolute; left: 0; top: 0; width: 0; height: 0; transform-origin: 0 0; direction: ltr; }
svg.links { position: absolute; left: 0; top: 0; width: 1px; height: 1px; overflow: visible; pointer-events: none; }

/* ---------- الخريطة العامة ---------- */
.floor, .ped { display: none; position: absolute; border-radius: 50%; pointer-events: none; }
/* الأداء: العالم صورة مخزّنة أثناء الحركة، وضوء الوصلات طبقة مستقلة تتوقف أثناء الحركة وداخل المديرية */
.world.moving { will-change: transform; }
#ovFlow { will-change: transform; }
.moving #ovFlow, body.focus #ovFlow, body.focus .pulse { display: none; }
#ov { transition: opacity .5s, visibility 0s; }
body.focus #ov { opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .5s, visibility 0s .5s; }
.node { position: absolute; transform: translate(-50%, -50%); direction: rtl; text-align: center; cursor: pointer; transition: transform .2s, box-shadow .2s; } /* لا انتقال للشفافية: تعتيم مئات العناصر بانتقال يُنشئ مئات الطبقات */
.n-min { width: 136px; height: 136px; border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center; background: radial-gradient(circle at 35% 30%, #ffe9ad, #f2c14e 46%, #a06f12); color: #2a1c02; box-shadow: 0 0 70px rgba(242, 193, 78, .55), 0 0 0 7px rgba(242, 193, 78, .14); z-index: 3; }
.n-min b { font-size: 18px; }
.n-min span { font-size: 12px; opacity: .85; }
.pulse { position: absolute; inset: -4px; border-radius: 50%; border: 2px solid rgba(242, 193, 78, .65); animation: pulse 3.2s ease-out infinite; pointer-events: none; }
@keyframes pulse { to { transform: scale(1.75); opacity: 0; } }
.n-dep { width: 156px; padding: 9px 8px; border-radius: 15px; background: linear-gradient(160deg, color-mix(in srgb, var(--c) 28%, #0c1428), #0c1428); border: 1.5px solid var(--c); box-shadow: 0 0 26px color-mix(in srgb, var(--c) 45%, transparent); z-index: 2; }
.n-dep b { display: block; font-size: 14px; }
.n-dep span { font-size: 11px; color: var(--c); }
.n-dir { width: 106px; min-height: 44px; padding: 5px 6px; border-radius: 12px; background: color-mix(in srgb, var(--c) 15%, #0b1224); border: 1px solid color-mix(in srgb, var(--c) 72%, transparent); box-shadow: 0 0 14px color-mix(in srgb, var(--c) 28%, transparent); display: flex; flex-direction: column; justify-content: center; z-index: 2; }
.n-dir b { font-size: 12px; line-height: 1.25; font-weight: 600; }
.n-dir .met { font-size: 9.5px; color: var(--c); margin-top: 1px; }
.n-dir.small { width: 66px; min-height: 26px; padding: 3px; border-radius: 9px; }
.n-dir.small b { font-size: 11px; }
.n-dir:hover, .n-dep:hover { transform: translate(-50%, -50%) scale(1.12); z-index: 6; box-shadow: 0 0 34px var(--c); }
.n-dept, .n-sec { width: 0; height: 0; }
.n-dept i, .n-sec i { position: absolute; left: -4.5px; top: -4.5px; width: 9px; height: 9px; border-radius: 50%; background: var(--c); box-shadow: 0 0 8px var(--c); }
.n-sec i { left: -2.5px; top: -2.5px; width: 5px; height: 5px; opacity: .85; box-shadow: none; }
.lbl { position: absolute; left: 0; top: 0; transform-origin: 0 0; white-space: nowrap; font-size: 8px; color: #cfd8ee; display: none; }
.n-sec .lbl { font-size: 6.5px; color: var(--mut); }
[data-z=mid] .n-dept .lbl, [data-z=near] .lbl { display: block; }

.orbit { fill: none; stroke: rgba(255, 255, 255, .055); stroke-dasharray: 3 8; }
.lk { fill: none; stroke: var(--c); stroke-opacity: .4; stroke-width: 1.2; }
.l-dep { stroke-width: 2.8; stroke-opacity: .65; }
.l-dir { stroke-width: 1.6; stroke-opacity: .5; }
.l-dept { stroke-width: .9; }
.l-sec { stroke-width: .6; stroke-opacity: .3; }
.flow { fill: none; stroke: #fff; stroke-opacity: .8; stroke-width: 1.9; stroke-linecap: round; stroke-dasharray: 1 27; animation: flow 2.4s linear infinite; }
@keyframes flow { to { stroke-dashoffset: -28; } }
.f-dir { display: none; }
.f-dir.hl { display: inline; }
.hov .node:not(.hl), .hov .lk:not(.hl), .hov .flow:not(.hl) { opacity: .15; }
.lk.hl { stroke-opacity: 1; }
.xarc { fill: none; stroke: #fff; stroke-opacity: .6; stroke-dasharray: 5 5; animation: dash 1s linear infinite; }
.node.xl { box-shadow: 0 0 0 1.5px #fff, 0 0 22px rgba(255, 255, 255, .5); }
@keyframes dash { to { stroke-dashoffset: -20; } }

/* ---------- داخل المديرية ---------- */
#fx { opacity: 0; pointer-events: none; transition: opacity .3s; }
body.focus #fx { opacity: 1; pointer-events: auto; transition: opacity .5s .2s; }
.ftitle { position: absolute; transform: translateX(-50%); text-align: center; direction: rtl; white-space: nowrap; }
.ftitle small { display: block; color: var(--c); font-size: 14px; }
.ftitle b { display: block; font-size: 36px; line-height: 1.3; }
.ftitle span { color: var(--mut); font-size: 14px; }
.deptbox { position: absolute; border-radius: 22px; border: 1px solid color-mix(in srgb, var(--c) 32%, transparent); background: linear-gradient(180deg, color-mix(in srgb, var(--c) 10%, transparent), rgba(255, 255, 255, .015)); }
.deptbox label { position: absolute; top: 10px; left: 0; right: 0; text-align: center; font-size: 15.5px; font-weight: 700; color: var(--c); direction: rtl; }
.secbox { position: absolute; border-radius: 13px; background: rgba(255, 255, 255, .035); }
.secbox label { position: absolute; top: 5px; right: 12px; font-size: 11.5px; color: var(--mut); direction: rtl; }
.flashbox { animation: flashbox 1.4s 2; }
@keyframes flashbox { 50% { box-shadow: 0 0 0 2px var(--gold), 0 0 40px rgba(242, 193, 78, .5); } }
@keyframes fade { from { opacity: 0; } }

.card { position: absolute; direction: rtl; display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 14px; background: linear-gradient(160deg, #18233f, #0e1630); border: 1px solid rgba(255, 255, 255, .1); box-shadow: 0 6px 18px rgba(0, 0, 0, .35); cursor: pointer; animation: cardIn .55s cubic-bezier(.2, .8, .2, 1) backwards; animation-delay: calc(var(--i) * 13ms + .3s); transition: border-color .2s, box-shadow .2s, transform .2s; }
@keyframes cardIn { from { opacity: 0; transform: translateY(28px) scale(.78); } }
.card:hover { transform: translateY(-3px); border-color: var(--c); box-shadow: 0 10px 26px rgba(0, 0, 0, .5), 0 0 0 1px var(--c); z-index: 4; }
.av { flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 14px; background: color-mix(in srgb, var(--c) 22%, #0b1224); color: var(--c); border: 1.5px solid color-mix(in srgb, var(--c) 60%, transparent); }
.tx { min-width: 0; flex: 1; text-align: right; }
.tx b { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx span { display: block; font-size: 10.5px; color: var(--mut); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cm { position: absolute; top: 6px; left: 8px; display: flex; gap: 3px; }
.cm i { width: 7px; height: 7px; border-radius: 50%; }
.ext { position: absolute; bottom: 4px; left: 9px; font-size: 9.5px; color: var(--mut); font-style: normal; }
.r-director { background: linear-gradient(160deg, color-mix(in srgb, var(--c) 32%, #18233f), #0e1630); border-color: var(--c); box-shadow: 0 0 34px color-mix(in srgb, var(--c) 42%, transparent); }
.r-director .av { width: 54px; height: 54px; font-size: 18px; }
.r-director .tx b { font-size: 16px; }
.r-director .tx span { font-size: 12px; }
.r-head { border-color: color-mix(in srgb, var(--c) 60%, transparent); background: linear-gradient(160deg, color-mix(in srgb, var(--c) 16%, #18233f), #0e1630); }
.r-head .tx b { font-size: 14px; }
.r-chief .av { border-style: double; border-width: 3px; }
.ghost { border: 1.5px dashed rgba(255, 255, 255, .2); background: transparent; box-shadow: none; color: var(--mut); justify-content: center; font-size: 11px; padding: 0; border-radius: 9px; cursor: default; }
.ghost:hover { transform: none; border-color: rgba(255, 255, 255, .2); box-shadow: none; }
.card.lit { border-color: var(--c); }
.card.sel { box-shadow: 0 0 0 2px var(--gold), 0 0 30px rgba(242, 193, 78, .45); border-color: var(--gold); }
.card.ring { box-shadow: 0 0 0 2px var(--ring), 0 0 28px var(--ring); border-color: var(--ring); }
.card.flash { animation: flash 1.2s 2; }
@keyframes flash { 50% { box-shadow: 0 0 0 3px var(--gold), 0 0 46px var(--gold); transform: scale(1.06); } }

.rel { fill: none; stroke-linecap: round; }
.in #fxSvg { animation: fade .6s .7s backwards; }
.in #fxBoxes { animation: fade .5s .1s backwards; }
.r-hier { stroke: #f2c14e; stroke-width: 1.6; stroke-opacity: .7; marker-end: url(#arH); }
.r-hier.sub { opacity: 0; }
.r-coord { stroke: #3dd6c6; stroke-dasharray: 7 6; stroke-opacity: .38; }
.r-deleg { stroke: #ff9f5a; stroke-width: 2.2; stroke-dasharray: 1 7; stroke-opacity: .95; marker-end: url(#arD); }
.hov .rel:not(.lit) { opacity: .05; }
.hov .rel.lit { opacity: 1; stroke-opacity: 1; }
.hov .r-coord.lit { animation: dash .9s linear infinite; }
.hov .card:not(.lit) { opacity: .2; }
.hide-hier .r-hier, .hide-coord .r-coord, .hide-deleg .r-deleg { display: none; }

/* ---------- الواجهة ---------- */
#top { position: fixed; top: 0; left: 0; right: 0; height: 60px; display: flex; align-items: center; gap: 16px; padding: 0 18px; background: linear-gradient(180deg, rgba(6, 10, 20, .94), rgba(6, 10, 20, 0)); z-index: 20; pointer-events: none; }
#top > * { pointer-events: auto; }
.brand b { font-size: 17px; }
.brand em { font-style: normal; font-size: 11px; background: rgba(242, 193, 78, .14); color: var(--gold); border: 1px solid rgba(242, 193, 78, .4); padding: 2px 9px; border-radius: 99px; margin-inline-start: 9px; }
#crumbs { font-size: 13px; color: var(--mut); display: flex; gap: 7px; white-space: nowrap; }
#crumbs a { color: var(--ink); cursor: pointer; }
#crumbs a:hover { color: var(--gold); }
.sp { flex: 1; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 11px; overflow: hidden; background: rgba(12, 18, 36, .7); transition: opacity .3s; }
.seg button { background: none; border: 0; padding: 7px 12px; font-size: 12.5px; color: var(--mut); cursor: pointer; }
.seg button.on { background: rgba(242, 193, 78, .16); color: var(--gold); }
body.focus .seg { opacity: 0; pointer-events: none; }
#search { position: relative; }
#q { width: 270px; padding: 8px 13px; border-radius: 11px; border: 1px solid var(--line); background: rgba(12, 18, 36, .8); outline: none; font-size: 13px; }
#q:focus { border-color: var(--gold); }
#res { position: absolute; top: 42px; left: 0; width: 330px; border-radius: 13px; background: rgba(12, 18, 36, .97); border: 1px solid var(--line); overflow: hidden; display: none; box-shadow: 0 16px 40px rgba(0, 0, 0, .5); }
#res.on { display: block; }
#res div { padding: 8px 13px; cursor: pointer; border-bottom: 1px solid rgba(255, 255, 255, .05); }
#res div:hover { background: rgba(242, 193, 78, .1); }
#res b { display: block; font-size: 13px; }
#res span { font-size: 11px; color: var(--mut); }

#back { position: fixed; top: 66px; right: 18px; z-index: 20; padding: 8px 15px; border-radius: 11px; border: 1px solid rgba(242, 193, 78, .45); background: rgba(242, 193, 78, .12); color: var(--gold); cursor: pointer; font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .3s; }
body.focus #back { opacity: 1; pointer-events: auto; }

#panel { position: fixed; top: 70px; left: 16px; bottom: 16px; width: 330px; border-radius: 20px; background: rgba(12, 18, 36, .93); border: 1px solid var(--line); padding: 18px; overflow: auto; z-index: 25; transform: translateX(-380px); transition: transform .35s cubic-bezier(.2, .8, .2, 1); }
#panel.on { transform: none; }
#panel .x { position: absolute; top: 10px; left: 12px; background: none; border: 0; font-size: 22px; color: var(--mut); cursor: pointer; }
.ph { text-align: center; }
.av.big { width: 76px; height: 76px; font-size: 26px; margin: 0 auto 8px; box-shadow: 0 0 30px color-mix(in srgb, var(--c) 40%, transparent); }
.ph h2 { margin: 0; font-size: 20px; }
.ph p { margin: 2px 0 0; color: var(--c); font-size: 13px; }
.path { margin: 12px 0; font-size: 11.5px; color: var(--mut); line-height: 1.7; text-align: center; }
.kv { display: flex; gap: 8px; }
.kv div { flex: 1; text-align: center; background: rgba(255, 255, 255, .04); border-radius: 12px; padding: 8px 4px; }
.kv b { display: block; font-size: 18px; }
.kv span { font-size: 10.5px; color: var(--mut); }
#panel h3 { margin: 16px 0 6px; font-size: 13px; padding-inline-start: 10px; border-inline-start: 3px solid var(--gold); }
#panel h3.t-coord { border-color: #3dd6c6; }
#panel h3.t-deleg { border-color: #ff9f5a; }
#panel h3.t-comm { border-color: #c77dff; }
#panel ul { list-style: none; margin: 0; padding: 0; }
#panel li { padding: 6px 8px; border-radius: 9px; font-size: 13px; position: relative; }
#panel li:nth-child(odd) { background: rgba(255, 255, 255, .03); }
#panel li small { display: block; color: var(--mut); font-size: 11px; }
#panel li em { position: absolute; left: 8px; top: 7px; font-style: normal; font-size: 10.5px; color: #3dd6c6; }
#panel a { color: var(--ink); cursor: pointer; border-bottom: 1px dotted var(--mut); }
#panel a:hover { color: var(--gold); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-inline-end: 6px; }

#legend, #stats, #olegend, #hint { position: fixed; z-index: 15; transition: opacity .3s; }
#legend { bottom: 14px; left: 50%; transform: translateX(-50%); display: flex; gap: 7px; flex-wrap: wrap; justify-content: center; max-width: 92vw; opacity: 0; pointer-events: none; }
body.focus #legend { opacity: 1; pointer-events: auto; }
.chip { display: flex; align-items: center; gap: 7px; padding: 6px 11px; border-radius: 99px; background: rgba(12, 18, 36, .88); border: 1px solid var(--line); font-size: 12px; cursor: pointer; white-space: nowrap; }
.chip.off { opacity: .35; }
.chip:hover { border-color: var(--gold); }
.ln { width: 26px; height: 0; border-top: 2px solid #f2c14e; }
.ln.coord { border-top: 2px dashed #3dd6c6; }
.ln.deleg { border-top: 3px dotted #ff9f5a; }
.chip .dot { margin: 0; }
.sepc { width: 1px; background: var(--line); margin: 0 4px; }
#stats { bottom: 14px; left: 50%; transform: translateX(-50%); display: flex; gap: 22px; padding: 9px 22px; border-radius: 16px; background: rgba(12, 18, 36, .8); border: 1px solid var(--line); }
#stats div { text-align: center; }
#stats b { display: block; font-size: 19px; color: var(--gold); }
#stats span { font-size: 11px; color: var(--mut); }
#olegend { bottom: 14px; right: 16px; padding: 10px 13px; border-radius: 14px; background: rgba(12, 18, 36, .8); border: 1px solid var(--line); font-size: 11.5px; line-height: 1.9; }
#olegend .bar { width: 170px; height: 9px; border-radius: 9px; margin: 4px 0; }
#olegend .ends { display: flex; justify-content: space-between; color: var(--mut); }
#hint { bottom: 16px; left: 16px; font-size: 11.5px; color: var(--mut); }
body.focus #stats, body.focus #olegend, body.focus #hint { opacity: 0; pointer-events: none; }
@media (max-width: 1100px) { #olegend, #hint, .brand em { display: none; } #q { width: 190px; } }
