@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  --ink: #0a0e1a;
  --panel: #121829;
  --panel-2: #171f34;
  --line: #212c47;
  --text: #e6eaf5;
  --muted: #7c89a8;
  --signal: #4f7cff;
  --mint: #35d6a4;
  --amber: #f5a524;
  --rose: #ff5d6c;
  --r: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--ink);
  color: var(--text);
  font-family: 'Cairo', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}
.mono { font-family: 'IBM Plex Mono', monospace; direction: ltr; unicode-bidi: embed; }
a { color: var(--signal); text-decoration: none; }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ── تسجيل الدخول ─────────────────────────── */
.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 380px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 20px; padding: 32px 24px;
}
.login-card h1 { font-size: 22px; margin: 0 0 4px; }
.login-card p.sub { color: var(--muted); margin: 0 0 24px; font-size: 14px; }

/* ── التخطيط ──────────────────────────────── */
.layout { display: flex; min-height: 100dvh; }
.sidebar {
  width: 240px; flex-shrink: 0; background: var(--panel);
  border-inline-start: 1px solid var(--line);
  padding: 20px 12px; position: sticky; top: 0; height: 100dvh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 10px 20px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(140deg, var(--signal), #8b5cf6);
  display: grid; place-items: center; font-weight: 700; font-size: 15px;
}
.brand strong { font-size: 15px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 10px 12px; border-radius: 10px; border: 0; background: none;
  color: var(--muted); font: inherit; cursor: pointer; text-align: start;
}
.nav-item:hover { background: var(--panel-2); color: var(--text); }
.nav-item.active { background: color-mix(in srgb, var(--signal) 16%, transparent); color: var(--text); }
.nav-item .badge { margin-inline-start: auto; }
.nav-sep { color: var(--muted); font-size: 11px; padding: 16px 12px 6px; letter-spacing: .06em; }

.main { flex: 1; min-width: 0; padding: 20px; padding-bottom: 100px; }
.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.topbar h2 { margin: 0; font-size: 20px; }
.topbar .spacer { flex: 1; }

/* ── شريط الجوال السفلي ───────────────────── */
.tabbar { display: none; }
@media (max-width: 860px) {
  .sidebar { display: none; }
  .main { padding: 14px 14px 92px; }
  .tabbar {
    display: flex; position: fixed; inset-inline: 0; bottom: 0; z-index: 40;
    background: color-mix(in srgb, var(--panel) 94%, transparent);
    backdrop-filter: blur(14px); border-top: 1px solid var(--line);
    padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
  }
  .tabbar button {
    flex: 1; background: none; border: 0; color: var(--muted); font: inherit;
    font-size: 11px; display: grid; gap: 2px; justify-items: center; padding: 4px 0; cursor: pointer;
  }
  .tabbar button.active { color: var(--signal); }
  .tabbar button span.ic { font-size: 18px; }
}

/* ── البطاقات والشبكات ────────────────────── */
.grid { display: grid; gap: 12px; }
.grid.stats { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.grid.cards { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r); padding: 16px;
}
.stat .n { font-size: 26px; font-weight: 700; font-family: 'IBM Plex Mono', monospace; }
.stat .l { color: var(--muted); font-size: 13px; }
.stat.warn .n { color: var(--amber); }
.stat.good .n { color: var(--mint); }

.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.stack { display: grid; gap: 12px; }
.muted { color: var(--muted); font-size: 13px; }
.title { font-weight: 600; }

/* الشريحة التقنية — العنصر المميّز */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: 'IBM Plex Mono', monospace; font-size: 12px; direction: ltr;
  background: color-mix(in srgb, var(--signal) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--signal) 26%, transparent);
  color: #b9caff; padding: 3px 8px; border-radius: 7px; cursor: pointer;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chip:active { background: color-mix(in srgb, var(--signal) 24%, transparent); }
.chip.copied { border-color: var(--mint); color: var(--mint); }

.badge {
  font-size: 11px; padding: 2px 9px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted); white-space: nowrap;
}
.badge.ok { color: var(--mint); border-color: color-mix(in srgb, var(--mint) 40%, transparent); }
.badge.warn { color: var(--amber); border-color: color-mix(in srgb, var(--amber) 40%, transparent); }
.badge.bad { color: var(--rose); border-color: color-mix(in srgb, var(--rose) 40%, transparent); }

/* ── النماذج ──────────────────────────────── */
label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
input, select, textarea {
  width: 100%; background: var(--ink); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 12px; font: inherit; font-size: 15px;
}
input:focus, select:focus, textarea:focus { border-color: var(--signal); outline: none; }
textarea { min-height: 80px; resize: vertical; }
input[type=file] { padding: 9px; color: var(--muted); }

button, .btn {
  background: var(--signal); color: #fff; border: 0; border-radius: 10px;
  padding: 11px 16px; font: inherit; font-weight: 600; cursor: pointer;
}
button:disabled { opacity: .55; cursor: default; }
.btn-ghost { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); }
.btn-danger { background: color-mix(in srgb, var(--rose) 18%, transparent); color: var(--rose); border: 1px solid color-mix(in srgb, var(--rose) 35%, transparent); }
.btn-sm { padding: 7px 11px; font-size: 13px; }

.msg { font-size: 13px; margin: 0; min-height: 18px; }
.msg.err { color: var(--rose); }
.msg.ok { color: var(--mint); }

/* ── النافذة المنبثقة ─────────────────────── */
.modal-bg {
  position: fixed; inset: 0; background: rgba(4, 7, 15, .72);
  display: grid; place-items: end center; z-index: 60; padding: 0;
}
.modal {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 20px 20px 0 0; padding: 20px;
  width: 100%; max-width: 520px; max-height: 88dvh; overflow-y: auto;
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
  animation: rise .18s ease-out;
}
@keyframes rise { from { transform: translateY(14px); opacity: .6 } }
@media (min-width: 861px) {
  .modal-bg { place-items: center; }
  .modal { border-radius: 20px; }
}
.modal h3 { margin: 0 0 14px; font-size: 17px; }

/* ── القوائم ──────────────────────────────── */
.list-item {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r); padding: 14px; display: grid; gap: 8px;
}
.list-item .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
.empty strong { display: block; color: var(--text); margin-bottom: 6px; }

.toast {
  position: fixed; inset-inline: 16px; bottom: 100px; z-index: 90;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px; font-size: 14px;
  animation: rise .18s ease-out; max-width: 420px; margin: 0 auto;
}
.toast.err { border-color: color-mix(in srgb, var(--rose) 45%, transparent); }
.toast.ok { border-color: color-mix(in srgb, var(--mint) 45%, transparent); }

/* ── الصفحات المستقلة (تثبيت / UDID) ──────── */
body.standalone { display: grid; place-items: center; min-height: 100dvh; padding: 24px; }
.card-page {
  width: 100%; max-width: 420px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 20px; padding: 28px 22px;
}
.card-page h1 { font-size: 21px; margin: 0 0 8px; }
.app-hero { text-align: center; }
.app-icon { width: 84px; height: 84px; border-radius: 20px; object-fit: cover; margin-bottom: 12px; }
.app-icon.placeholder { background: var(--panel-2); display: inline-block; }
.meta { display: flex; justify-content: center; gap: 22px; margin: 18px 0; padding: 0; }
.meta div { text-align: center; }
.meta dt { color: var(--muted); font-size: 12px; }
.meta dd { margin: 2px 0 0; font-weight: 600; }
.desc { color: var(--muted); font-size: 14px; }
.btn-install {
  display: block; background: var(--signal); color: #fff; font-weight: 700;
  padding: 14px; border-radius: 12px; margin-top: 16px;
}
.hint { color: var(--muted); font-size: 12px; margin-top: 14px; }
