/* ============ مراقبة عالم محمول ============ */
@font-face { font-family: 'Cairo'; 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+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: 'Cairo'; 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+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: 'Cairo'; 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+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: 'Cairo'; font-weight: 800; font-display: swap; src: url(/fonts/cairo-arabic-800-normal.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: 'Cairo'; font-weight: 400; font-display: swap; src: url(/fonts/cairo-latin-400-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+2000-206F; }
@font-face { font-family: 'Cairo'; font-weight: 600; font-display: swap; src: url(/fonts/cairo-latin-600-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+2000-206F; }
@font-face { font-family: 'Cairo'; font-weight: 700; font-display: swap; src: url(/fonts/cairo-latin-700-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+2000-206F; }
@font-face { font-family: 'Cairo'; font-weight: 800; font-display: swap; src: url(/fonts/cairo-latin-800-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+2000-206F; }

:root {
  --bg: #070f1c; --bg-2: #0b1628; --card: #0e1b2f; --card-2: #13233b; --line: rgba(148, 178, 220, .12); --line-2: rgba(148, 178, 220, .2);
  --text: #eaf1fb; --text-2: #b5c3d8; --muted: #7d90ab;
  --green: #22c58b; --green-bg: rgba(34, 197, 139, .12); --yellow: #f5b83d; --yellow-bg: rgba(245, 184, 61, .13);
  --red: #ff5d5d; --red-bg: rgba(255, 93, 93, .13); --grey: #607089; --blue: #4f9dff; --blue-bg: rgba(79, 157, 255, .14);
  --radius: 18px; --shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 10px 30px rgba(0, 0, 0, .25);
  --font: 'Cairo', system-ui, 'Segoe UI', Tahoma, sans-serif;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #eef2f8; --bg-2: #e6ecf5; --card: #ffffff; --card-2: #f4f7fb; --line: rgba(15, 35, 70, .09); --line-2: rgba(15, 35, 70, .16);
    --text: #0f1f36; --text-2: #3d5170; --muted: #6b7d96; --shadow: 0 1px 2px rgba(15, 35, 70, .05), 0 8px 24px rgba(15, 35, 70, .07);
    color-scheme: light;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font); font-size: 15px; line-height: 1.6; color: var(--text); -webkit-font-smoothing: antialiased;
  background: radial-gradient(1200px 500px at 85% -10%, rgba(79, 157, 255, .14), transparent 60%), radial-gradient(800px 400px at 0% 0%, rgba(34, 197, 139, .07), transparent 60%), var(--bg);
  background-attachment: fixed; min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; background: none; border: 0; }
svg { flex-shrink: 0; }
.wrap { max-width: 1180px; margin: 0 auto; padding: max(18px, env(safe-area-inset-top)) 18px 48px; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- الشريط العلوي ---------- */
.top { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.brand { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.logo { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; background: linear-gradient(145deg, #12305a, #0a1a31); border: 1px solid var(--line-2); box-shadow: var(--shadow); }
.brand h1 { font-size: 19px; font-weight: 800; margin: 0; line-height: 1.25; letter-spacing: -.2px; }
.brand p { margin: 0; font-size: 12.5px; color: var(--muted); }
.actions { display: flex; gap: 8px; }
.ib { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--card); border: 1px solid var(--line); color: var(--text-2); box-shadow: var(--shadow); transition: .15s; position: relative; }
.ib:hover { color: var(--text); border-color: var(--line-2); transform: translateY(-1px); }
.ib.on { color: var(--green); }
.ib .badge { position: absolute; top: -4px; inset-inline-start: -4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--red); color: #fff; font-size: 11px; font-weight: 800; display: grid; place-items: center; }
.ib.spin svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(-360deg); } }

/* ---------- لوحة الحالة العامة ---------- */
.hero { border-radius: 22px; padding: 18px 20px; display: flex; align-items: center; gap: 16px; margin-bottom: 18px; border: 1px solid var(--line); background: var(--card); box-shadow: var(--shadow); position: relative; overflow: hidden; }
.hero::before { content: ''; position: absolute; inset: 0; background: linear-gradient(100deg, var(--tint), transparent 70%); pointer-events: none; }
.hero.green { --tint: var(--green-bg); } .hero.yellow { --tint: var(--yellow-bg); } .hero.red { --tint: var(--red-bg); } .hero.grey { --tint: transparent; }
.hero-ic { width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center; position: relative; }
.hero.green .hero-ic { background: var(--green-bg); color: var(--green); } .hero.yellow .hero-ic { background: var(--yellow-bg); color: var(--yellow); } .hero.red .hero-ic { background: var(--red-bg); color: var(--red); }
.hero-tx { flex: 1; position: relative; }
.hero-tx b { font-size: 18px; font-weight: 800; display: block; line-height: 1.35; }
.hero-tx span { color: var(--text-2); font-size: 13.5px; }
.counts { display: flex; gap: 8px; position: relative; flex-wrap: wrap; }
.count { display: flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 12px; background: var(--card-2); border: 1px solid var(--line); font-weight: 700; font-size: 13px; }

/* ---------- البطاقات ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
a.tcard { display: block; transition: transform .15s, border-color .15s; position: relative; overflow: hidden; }
a.tcard:hover { transform: translateY(-2px); border-color: var(--line-2); }
a.tcard::after { content: ''; position: absolute; inset-inline-start: 0; top: 0; bottom: 0; width: 4px; background: var(--st); }
.tcard.green { --st: var(--green); } .tcard.yellow { --st: var(--yellow); } .tcard.red { --st: var(--red); } .tcard.grey { --st: var(--grey); }
.t-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.t-ic { width: 42px; height: 42px; border-radius: 12px; background: var(--card-2); border: 1px solid var(--line); display: grid; place-items: center; color: var(--blue); }
.t-name { flex: 1; min-width: 0; }
.t-name b { display: block; font-size: 16px; font-weight: 800; line-height: 1.35; }
.t-name small { color: var(--muted); font-size: 12.5px; }
.status { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.status.green { background: var(--green-bg); color: var(--green); } .status.yellow { background: var(--yellow-bg); color: var(--yellow); }
.status.red { background: var(--red-bg); color: var(--red); } .status.grey { background: var(--card-2); color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; }
.status.red .dot { animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

.gauges { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 14px; }
.gauge { display: grid; justify-items: center; gap: 2px; }
.gauge svg { width: 78px; height: 78px; }
.gauge .g-v { font-size: 17px; font-weight: 800; }
.gauge .g-l { font-size: 12px; color: var(--muted); font-weight: 600; }
.gauge .g-s { font-size: 11px; color: var(--muted); }

.strip-h { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.strip-h b { color: var(--text-2); font-weight: 700; }
.strip { display: grid; grid-template-columns: repeat(48, 1fr); gap: 2px; height: 22px; margin-bottom: 14px; }
.strip i { border-radius: 3px; background: var(--card-2); }
.strip i.g { background: var(--green); opacity: .85; } .strip i.y { background: var(--yellow); } .strip i.r { background: var(--red); }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tile { background: var(--card-2); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; min-width: 0; }
.tile span { display: flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.tile b { display: block; font-size: 14.5px; font-weight: 800; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; unicode-bidi: plaintext; text-align: right; }
.tile.bad b { color: var(--red); } .tile.warn b { color: var(--yellow); } .tile.good b { color: var(--green); }

.alerts { display: grid; gap: 8px; margin-top: 12px; }
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 12px; background: var(--yellow-bg); color: var(--text); font-size: 13.5px; font-weight: 600; }
.alert svg { color: var(--yellow); margin-top: 2px; }
.alert.critical { background: var(--red-bg); } .alert.critical svg { color: var(--red); }
.alert.resolved { background: var(--card-2); color: var(--text-2); } .alert.resolved svg { color: var(--green); }
.alert small { display: block; color: var(--muted); font-size: 11.5px; font-weight: 500; }
.alert div { flex: 1; min-width: 0; }

/* ---------- صفحة التفاصيل ---------- */
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-weight: 600; font-size: 14px; }
.seg { display: inline-flex; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 2px; }
.seg button { padding: 6px 14px; border-radius: 9px; font-size: 13px; font-weight: 700; color: var(--muted); }
.seg button.on { background: var(--blue); color: #fff; }
.bar-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 6px 0 14px; flex-wrap: wrap; }
.charts { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; margin-bottom: 16px; }
.chart-h { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.chart-h span { font-size: 13px; color: var(--muted); font-weight: 600; }
.chart-h b { font-size: 20px; font-weight: 800; }
.chart svg { width: 100%; height: 120px; display: block; overflow: visible; }
.axis { font-size: 10px; fill: var(--muted); font-family: var(--font); }
.cols { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; }
.card h3 { margin: 0 0 10px; font-size: 15px; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.list { display: grid; }
.li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.li:last-child { border-bottom: 0; }
.li .k { flex: 1; color: var(--text-2); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li .v { font-weight: 700; white-space: nowrap; }
.ok { color: var(--green); } .bad { color: var(--red); } .warn { color: var(--yellow); } .muted { color: var(--muted); }
.timeline { display: grid; gap: 0; }
.tl { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.tl:last-child { border-bottom: 0; }
.tl i { width: 10px; height: 10px; border-radius: 50%; margin-top: 7px; flex-shrink: 0; }
.tl i.critical { background: var(--red); } .tl i.warn { background: var(--yellow); } .tl i.resolved { background: var(--green); }
.tl div { flex: 1; font-size: 13.5px; font-weight: 600; }
.tl small { display: block; color: var(--muted); font-weight: 500; font-size: 12px; }

/* ---------- الدخول ---------- */
.login { min-height: 92vh; display: grid; place-items: center; padding: 20px; }
.login form { width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--line); border-radius: 24px; padding: 28px 24px; display: grid; gap: 14px; box-shadow: var(--shadow); }
.login .logo { width: 60px; height: 60px; border-radius: 18px; margin: 0 auto 4px; }
.login h1 { margin: 0; font-size: 21px; font-weight: 800; text-align: center; }
.login p { margin: -6px 0 6px; text-align: center; color: var(--muted); font-size: 13.5px; }
label { font-size: 13px; color: var(--text-2); font-weight: 600; display: grid; gap: 6px; }
input { font: inherit; color: var(--text); background: var(--card-2); border: 1px solid var(--line-2); border-radius: 12px; padding: 11px 14px; width: 100%; }
input:focus { outline: 2px solid var(--blue); outline-offset: 1px; border-color: transparent; }
.btn-main { height: 46px; border-radius: 12px; background: linear-gradient(180deg, #5aa6ff, #3b86ec); color: #fff; font-weight: 800; font-size: 15px; box-shadow: 0 8px 20px rgba(59, 134, 236, .3); }
.err { color: var(--red); font-size: 13px; text-align: center; font-weight: 600; }
.empty { text-align: center; color: var(--muted); padding: 34px 10px; }

#toast { position: fixed; bottom: max(20px, env(safe-area-inset-bottom)); inset-inline: 0; display: grid; justify-items: center; pointer-events: none; z-index: 9; }
#toast div { background: #16263f; color: #fff; padding: 10px 18px; border-radius: 12px; font-size: 13.5px; font-weight: 600; box-shadow: 0 10px 30px rgba(0, 0, 0, .4); border: 1px solid rgba(255, 255, 255, .08); }

.skeleton { height: 260px; border-radius: var(--radius); background: linear-gradient(90deg, var(--card) 0%, var(--card-2) 50%, var(--card) 100%); background-size: 200% 100%; animation: sk 1.2s infinite; }
@keyframes sk { to { background-position: -200% 0; } }

@media (max-width: 560px) {
  .wrap { padding-inline: 14px; }
  .grid, .charts, .cols { grid-template-columns: 1fr; }
  .brand h1 { font-size: 17px; }
  .brand p { display: none; }
  .ib { width: 38px; height: 38px; }
  .hero { padding: 14px 16px; flex-wrap: wrap; }
  .hero-tx b { font-size: 16px; }
  .counts { width: 100%; }
  .gauge svg { width: 70px; height: 70px; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
