/* برق · لوحة المراقبة */
@font-face { font-family: 'Readex Pro'; src: url('fonts/ReadexPro.ttf') format('truetype'); font-weight: 160 700; font-display: swap; }
:root {
  --night: #120F26; --night2: #1C1838; --line-d: #2E2952; --line-d2: #3B3470; --muted-d: #ADA8CC;
  --violet: #5A35F0; --violet-d: #4527C9; --violet-l: #EDE9FF; --flash: #FFD23F;
  --ground: #F5F4FB; --card: #FFFFFF; --line: #E4E1F2; --line2: #EEECF7; --ink: #15122B; --muted: #5C5778;
  --ok: #0E7A4B; --ok-bg: #E2F5EC; --ok-fg: #0B5E3A; --ok-d: #5BE3A1;
  --bad: #B3261E; --bad-bg: #FBE9E7; --bad-fg: #7A1A14; --bad-d: #FF8A80;
  --wait: #8A5A00; --wait-bg: #FFF1CC; --wait-fg: #6B4600;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--ground); color: var(--ink); font-family: 'Readex Pro', system-ui, sans-serif; font-size: 15px; -webkit-text-size-adjust: 100%; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }
button, input, textarea { font-family: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--flash); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.rel { position: relative; }
.ring { position: absolute; border-radius: 50%; border: 1px solid var(--line-d); pointer-events: none; }

/* الشعار */
.logo { width: 44px; height: 44px; border-radius: 14px; background: var(--violet); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.logo svg { width: 24px; height: 24px; fill: var(--flash); }
.logo-xl { width: 72px; height: 72px; border-radius: 22px; }
.logo-xl svg { width: 40px; height: 40px; }

/* الدخول */
.login { position: relative; min-height: 100vh; background: var(--night); color: #fff; display: flex; align-items: center; justify-content: center; padding: 24px; overflow: hidden; }
.ring-a { left: -120px; top: -120px; width: 420px; height: 420px; }
.ring-b { left: -50px; top: -50px; width: 280px; height: 280px; border-color: var(--line-d2); }
.login-card { position: relative; width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 10px; }
.login-card h1 { font-size: 40px; font-weight: 700; margin-top: 8px; line-height: 1.2; }
.login-card label { font-size: 14px; color: var(--muted-d); margin-top: 18px; }
.login-card input { height: 54px; border-radius: 14px; border: 1px solid var(--line-d2); background: var(--night2); color: #fff; font-size: 17px; padding: 0 16px; text-align: left; }
.muted-dark { font-size: 14px; color: var(--muted-d); }
.s13 { font-size: 13px; }
.lh { line-height: 1.8; }
.form-error { color: var(--bad-d); font-size: 14px; }
.dlg .form-error { color: var(--bad); }

/* الأزرار */
.btn { min-height: 50px; padding: 0 22px; border-radius: 14px; border: 1px solid transparent; font-size: 15px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn-s { min-height: 44px; padding: 0 18px; border-radius: 12px; font-size: 14px; }
.btn-primary { background: var(--violet); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--violet-d); }
.btn-ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--violet); }
.btn-outline { border-color: var(--violet); color: var(--violet-d); font-weight: 600; background: #fff; }
.btn-danger { background: #fff; color: var(--bad); border-color: var(--bad); font-weight: 600; }
.btn-flash { margin-top: 14px; min-height: 56px; border-radius: 16px; background: var(--flash); color: var(--night); font-size: 17px; font-weight: 700; }
.btn-flash svg { width: 20px; height: 20px; fill: var(--night); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }
.top-line { border-top: 1px solid var(--line2); padding-top: 18px; }

/* الهيكل */
.shell { display: flex; flex-wrap: wrap; min-height: 100vh; }
.side { flex: 1 1 230px; background: var(--night); color: #fff; padding: 28px 18px; display: flex; flex-direction: column; gap: 28px; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px; }
.brand-text { display: flex; flex-direction: column; }
.brand-name { font-size: 24px; font-weight: 700; line-height: 1.2; }
.brand-sub { font-size: 12px; color: var(--muted-d); }
.nav-list { display: flex; flex-direction: column; gap: 6px; }
.nav-list a { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 0 14px; border-radius: 14px; color: #D6D2EE; font-size: 15px; }
.nav-list a svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.nav-list a:hover { background: var(--night2); }
.nav-list a[aria-current="page"] { background: var(--violet); color: #fff; font-weight: 600; }
.nav-out { margin-top: auto; min-height: 44px; border-radius: 12px; border: 1px solid var(--line-d2); background: transparent; color: var(--muted-d); font-size: 14px; }
.nav-out:hover { color: #fff; }
.main { flex: 999 1 560px; min-width: 0; padding: 32px; }
.page { display: flex; flex-direction: column; gap: 20px; }
.head { display: flex; flex-direction: column; gap: 4px; }
.head-row { flex-direction: row; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; }
.head-text { display: flex; flex-direction: column; gap: 4px; }
h1 { font-size: 32px; font-weight: 700; }
h2 { font-size: 20px; font-weight: 600; }
.h2-l { font-size: 22px; }
h3 { font-size: 17px; font-weight: 600; }
.sub { font-size: 15px; color: var(--muted); }
.sub-s { font-size: 14px; color: var(--muted); }
.pill-date { font-size: 14px; color: var(--muted); background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 10px 16px; }
.row { display: flex; flex-wrap: wrap; gap: 20px; }
.row-stretch { align-items: stretch; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 24px; padding: 22px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.scroll-x { overflow-x: auto; }

/* بطاقة حالة الهاتف */
.hero { position: relative; flex: 1 1 340px; min-height: 230px; background: var(--night); color: #fff; border-radius: 28px; padding: 26px; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; gap: 18px; }
.hero-ring-a { left: -80px; top: -80px; width: 260px; height: 260px; }
.hero-ring-b { left: -30px; top: -30px; width: 160px; height: 160px; border-color: var(--line-d2); }
.hero-bolt { position: absolute; left: 14px; top: 14px; width: 72px; height: 72px; border-radius: 50%; background: var(--violet); display: flex; align-items: center; justify-content: center; }
.hero-bolt svg { width: 36px; height: 36px; fill: var(--flash); }
.hero-top { position: relative; display: flex; flex-direction: column; gap: 6px; }
.live { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; color: var(--ok-d); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ok-d); box-shadow: 0 0 0 5px rgba(91, 227, 161, 0.18); }
.hero.off .live { color: var(--bad-d); }
.hero.off .dot { background: var(--bad-d); box-shadow: 0 0 0 5px rgba(255, 138, 128, 0.18); }
.hero.off .hero-bolt { background: var(--line-d2); }
.hero.off .hero-bolt svg { fill: var(--muted-d); }
.hero-title { font-size: 34px; font-weight: 700; line-height: 1.25; }
.hero-sub { font-size: 14px; color: var(--muted-d); }
.hero-stats { position: relative; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.chip-dark { background: var(--night2); border: 1px solid var(--line-d); border-radius: 14px; padding: 10px 12px; }
.chip-dark .k { font-size: 12px; color: var(--muted-d); }
.chip-dark .v { font-size: 18px; font-weight: 600; }

/* الأرقام */
.kpis { flex: 2 1 480px; display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 14px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 22px; padding: 20px; display: flex; flex-direction: column; justify-content: space-between; gap: 10px; min-height: 108px; }
.kpi .k { font-size: 15px; color: var(--muted); }
.kpi .n { font-size: 40px; font-weight: 700; line-height: 1; }
.kpi .amber { color: var(--wait); }
.kpi .red { color: var(--bad); }
.kpi-main { background: var(--violet); border-color: var(--violet); color: #fff; }
.kpi-main .k { color: #E6E0FF; }
.success { grid-column: 1 / -1; background: #fff; border: 1px solid var(--line); border-radius: 22px; padding: 18px 20px; display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
.success-text { display: flex; flex-direction: column; gap: 2px; flex: 1 1 200px; }
.success .k { font-size: 15px; color: var(--muted); }
.success .s { font-size: 14px; color: var(--muted); }
.success-pct { font-size: 36px; font-weight: 700; color: var(--ok); }
.bar { flex: 1 1 180px; height: 12px; border-radius: 999px; background: var(--line); overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: var(--ok); border-radius: 999px; transition: width 0.4s; }

/* المخطط */
.chart-card { flex: 3 1 420px; gap: 16px; }
.chart { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 8px; align-items: end; height: 170px; }
.chart div { background: #D9D2FB; border-radius: 6px 6px 2px 2px; min-height: 4px; transition: height 0.4s; }
.chart div.peak { background: var(--violet); }
.chart-labels { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 8px; font-size: 13px; color: var(--muted); direction: rtl; }
.chart-labels span { position: relative; height: 18px; }
.chart-labels b { position: absolute; left: 50%; transform: translateX(-50%); font-weight: 400; direction: ltr; white-space: nowrap; }

/* التنبيهات */
.alerts-card { flex: 2 1 320px; }
.alerts { display: flex; flex-direction: column; gap: 12px; }
.alert { display: flex; gap: 12px; align-items: flex-start; border-radius: 16px; padding: 14px; }
.alert svg { width: 22px; height: 22px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.alert .t { font-size: 15px; font-weight: 600; }
.alert .d { font-size: 14px; }
.alert-red { background: var(--bad-bg); color: var(--bad-fg); }
.alert-amber { background: var(--wait-bg); color: var(--wait-fg); }
.alert-violet { background: var(--violet-l); color: #2E1A8C; }
.empty { font-size: 15px; color: var(--muted); padding: 18px 4px; }

/* الجداول */
.table { display: flex; flex-direction: column; }
.tr { display: grid; gap: 12px; align-items: center; min-height: 56px; border-top: 1px solid var(--line2); font-size: 15px; }
.th { min-height: 52px; border-top: none; font-size: 14px; font-weight: 600; color: var(--muted); }
.t-recent { min-width: 560px; }
.t-recent .tr { grid-template-columns: 90px 1.3fr 1fr 1.4fr 110px; min-height: 52px; }
.t-msgs { min-width: 760px; }
.t-msgs .tr { grid-template-columns: 96px 1.3fr 0.8fr 1.1fr 1.5fr 0.9fr 110px; }
.t-apps { min-width: 620px; }
.t-apps .tr { grid-template-columns: 1fr 1.6fr 1fr 1fr 100px 150px; min-height: 64px; font-size: 16px; }
.t-apps .th { min-height: 48px; font-size: 14px; }
.c-time { color: var(--muted); direction: ltr; text-align: right; }
.c-phone { direction: ltr; text-align: right; font-weight: 500; }
.c-key { direction: ltr; text-align: right; color: var(--muted); letter-spacing: 1px; }
.c-muted { color: var(--muted); }
.c-strong { font-weight: 600; }
.pill { justify-self: start; padding: 6px 14px; border-radius: 999px; font-size: 14px; font-weight: 600; white-space: nowrap; }
.pill-sent, .pill-on { background: var(--ok-bg); color: var(--ok-fg); }
.pill-queued { background: var(--wait-bg); color: var(--wait-fg); }
.pill-failed, .pill-off { background: var(--bad-bg); color: var(--bad-fg); }
.card-table { padding: 8px 22px 14px; gap: 0; }
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding-top: 14px; border-top: 1px solid var(--line2); }
.pager-btns { display: flex; gap: 8px; }

/* فلترة الرسائل */
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button { min-height: 46px; padding: 0 18px; border-radius: 999px; border: 1px solid var(--line); background: #fff; color: var(--ink); font-size: 15px; }
.chips button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; font-weight: 600; }
.search { flex: 1 1 240px; display: flex; align-items: center; gap: 10px; min-height: 46px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line); background: #fff; }
.search svg { width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; flex-shrink: 0; }
.search input { flex: 1; min-width: 0; border: none; outline: none; background: transparent; font-size: 15px; color: var(--ink); }
.search:focus-within { border-color: var(--violet); }

/* القوالب */
.tpl-card { flex: 3 1 440px; padding: 24px; gap: 18px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.label { font-size: 15px; font-weight: 600; }
.editor { position: relative; border: 2px solid var(--violet); border-radius: 18px; background: #FBFAFF; min-height: 120px; }
.editor-back, .editor textarea { margin: 0; padding: 18px; font-family: inherit; font-size: 19px; line-height: 2; white-space: pre-wrap; overflow-wrap: break-word; word-break: normal; letter-spacing: 0; }
.editor-back { position: absolute; inset: 0; color: transparent; pointer-events: none; overflow: hidden; }
.editor-back mark { background: var(--flash); color: transparent; border-radius: 8px; box-shadow: 0 0 0 3px var(--flash); }
.editor textarea { position: relative; display: block; width: 100%; min-height: 116px; border: none; outline: none; resize: none; background: transparent; color: var(--ink); border-radius: 16px; overflow: hidden; }
.editor.bad { border-color: var(--bad); }
.editor-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; font-size: 14px; color: var(--muted); }
.editor-foot .bad { color: var(--bad); font-weight: 600; }
.limits { border-top: 1px solid var(--line2); padding-top: 18px; display: flex; flex-direction: column; gap: 12px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(124px, 1fr)); gap: 12px; }
.tiles-3 { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.tile { background: var(--ground); border-radius: 16px; padding: 14px 16px; }
.tile .k { font-size: 14px; color: var(--muted); }
.tile .v { font-size: 22px; font-weight: 700; }
.dark-card { position: relative; flex: 2 1 300px; min-width: 0; background: var(--night); color: #fff; border-radius: 24px; padding: 24px; overflow: hidden; display: flex; flex-direction: column; gap: 18px; }
.pv-ring-a { left: -90px; bottom: -90px; width: 280px; height: 280px; }
.pv-ring-b { left: -40px; bottom: -40px; width: 180px; height: 180px; border-color: var(--line-d2); }
.phone-box { background: var(--night2); border: 1px solid var(--line-d); border-radius: 22px; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.sender { display: flex; align-items: center; gap: 10px; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--line-d); display: flex; align-items: center; justify-content: center; }
.avatar svg { width: 20px; height: 20px; fill: none; stroke: var(--muted-d); stroke-width: 2; stroke-linecap: round; }
.sender-text { display: flex; flex-direction: column; }
.sender-name { font-size: 15px; font-weight: 600; }
.bubble { align-self: flex-start; max-width: 100%; background: #fff; color: var(--ink); border-radius: 18px 18px 18px 4px; padding: 14px 16px; font-size: 17px; line-height: 1.9; white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble b { white-space: nowrap; font-weight: 700; letter-spacing: 2px; direction: ltr; unicode-bidi: isolate; }

/* الهاتف والربط */
.dev-card { flex: 1 1 380px; padding: 24px; gap: 18px; }
.dev-id { display: flex; align-items: center; gap: 14px; }
.dev-icon { width: 56px; height: 56px; border-radius: 18px; background: var(--violet-l); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.dev-icon svg { width: 28px; height: 28px; fill: none; stroke: var(--violet-d); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.key-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.key-box { flex: 1 1 200px; min-height: 50px; display: flex; align-items: center; padding: 0 16px; border-radius: 14px; background: var(--ground); border: 1px solid var(--line); font-size: 16px; letter-spacing: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
.key-wrap { white-space: normal; word-break: break-all; padding: 14px 16px; letter-spacing: 0.5px; user-select: all; }
.alert-set { flex: 1 1 340px; padding: 24px; gap: 6px; }
.alert-set h2 { margin-bottom: 6px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 72px; border-top: 1px solid var(--line2); }
.sw-t { font-size: 16px; font-weight: 500; }
.switch { flex-shrink: 0; width: 60px; height: 44px; border: none; background: transparent; padding: 6px 0; }
.switch span { display: flex; align-items: center; justify-content: flex-start; width: 60px; height: 32px; border-radius: 999px; background: #8E89AB; padding: 0 4px; transition: background 0.2s; }
.switch i { width: 24px; height: 24px; border-radius: 50%; background: #fff; }
.switch[aria-checked="true"] span { background: var(--violet); justify-content: flex-end; }

/* النوافذ والتنبيه السريع */
.dlg { border: none; border-radius: 24px; padding: 0; width: min(460px, calc(100vw - 32px)); color: var(--ink); font-family: inherit; }
.dlg::backdrop { background: rgba(18, 15, 38, 0.6); }
.dlg form { padding: 26px; display: flex; flex-direction: column; gap: 14px; }
.dlg h2 { font-size: 22px; }
.dlg input { width: 100%; height: 52px; margin-top: 8px; border-radius: 14px; border: 1px solid var(--line); background: var(--ground); font-size: 17px; padding: 0 16px; color: var(--ink); }
.dlg input:focus { border-color: var(--violet); outline: none; }
.dlg-btns { margin-top: 6px; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--night); color: #fff; padding: 14px 22px; border-radius: 14px; font-size: 15px; z-index: 50; max-width: calc(100vw - 32px); box-shadow: 0 10px 30px rgba(18, 15, 38, 0.3); }
.toast.bad { background: var(--bad); }

@media (max-width: 640px) {
  .main { padding: 20px 16px; }
  h1 { font-size: 26px; }
  .side { gap: 16px; padding: 18px 16px; }
  .nav-list { flex-direction: row; flex-wrap: wrap; }
  .nav-list a { flex: 1 1 auto; }
  .nav-out { margin-top: 0; }
  .hero-title { font-size: 28px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
