/* ═════════ الألوان ═════════ */
:root {
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-2: #f0f3f5;
  --border: #e4e8ec;
  --text: #0f1a17;
  --text-2: #3d4a46;
  --muted: #6b7a76;
  --brand: #059669;
  --brand-2: #0d9488;
  --brand-soft: #e3f5ee;
  --on-brand: #ffffff;
  --ok: #16a34a;
  --ok-soft: #e7f6ec;
  --bad: #dc2626;
  --bad-soft: #fdecec;
  --warn: #b45309;
  --warn-soft: #fef3e2;
  --off: #94a3a0;
  --off-soft: #eef1f1;
  --fresh: #fff9db;
  --shadow: 0 1px 2px rgba(16, 24, 22, .04), 0 4px 16px rgba(16, 24, 22, .05);
  --shadow-lg: 0 20px 60px rgba(16, 24, 22, .18);
  --radius: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0f0e;
    --surface: #121816;
    --surface-2: #19211f;
    --border: #232d2a;
    --text: #e8efec;
    --text-2: #bac7c2;
    --muted: #82918c;
    --brand: #34d399;
    --brand-2: #2dd4bf;
    --brand-soft: #123128;
    --on-brand: #04261b;
    --ok: #4ade80;
    --ok-soft: #12301d;
    --bad: #f87171;
    --bad-soft: #3a1818;
    --warn: #fbbf24;
    --warn-soft: #36290c;
    --off: #6b7a76;
    --off-soft: #1c2422;
    --fresh: #2a2810;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0f0e;
  --surface: #121816;
  --surface-2: #19211f;
  --border: #232d2a;
  --text: #e8efec;
  --text-2: #bac7c2;
  --muted: #82918c;
  --brand: #34d399;
  --brand-2: #2dd4bf;
  --brand-soft: #123128;
  --on-brand: #04261b;
  --ok: #4ade80;
  --ok-soft: #12301d;
  --bad: #f87171;
  --bad-soft: #3a1818;
  --warn: #fbbf24;
  --warn-soft: #36290c;
  --off: #6b7a76;
  --off-soft: #1c2422;
  --fresh: #2a2810;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

/* ═════════ أساسيات ═════════ */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14.5px/1.6 "IBM Plex Sans Arabic", "Segoe UI", Tahoma, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { margin: 0; line-height: 1.3; }
h3 { font-size: 15.5px; font-weight: 600; }
p { margin: 0; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.grow { flex: 1; min-width: 0; }
.error { color: var(--bad); min-height: 1.4em; font-size: 13.5px; }
svg.i { flex: none; }

button { font: inherit; color: inherit; cursor: pointer; }
input {
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  width: 100%;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
input::placeholder { color: var(--muted); }

/* ═════════ أزرار ═════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 9px 16px; border-radius: 10px; font-weight: 600; font-size: 14px;
  transition: filter .15s, background .15s, transform .05s; white-space: nowrap;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; padding: 11px; }
.btn.sm { padding: 5px 11px; font-size: 13px; border-radius: 8px; }
.btn:hover:not(:disabled) { filter: brightness(1.06); }
.btn.soft-danger { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.btn.soft { background: var(--surface-2); border-color: transparent; }

.icon-btn {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.danger:hover { color: var(--bad); }

/* ═════════ تحميل ═════════ */
.splash { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 50; }
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--brand);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ═════════ هوية ═════════ */
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; flex: none;
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: var(--on-brand);
  box-shadow: 0 6px 18px color-mix(in srgb, var(--brand) 35%, transparent);
}
.brand-mark.sm { width: 30px; height: 30px; border-radius: 9px; }
.brand-mark.lg { width: 60px; height: 60px; border-radius: 18px; }
.brand-name { font-weight: 700; font-size: 16px; }
.brand-sub { color: var(--muted); font-size: 12.5px; }

/* ═════════ تسجيل الدخول ═════════ */
.login {
  min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background:
    radial-gradient(800px 400px at 85% -10%, color-mix(in srgb, var(--brand) 18%, transparent), transparent 70%),
    radial-gradient(600px 400px at 0% 110%, color-mix(in srgb, var(--brand-2) 12%, transparent), transparent 70%),
    var(--bg);
}
.login-wrap { width: 100%; max-width: 920px; display: grid; grid-template-columns: 1.1fr 1fr; gap: 48px; align-items: center; }
.login-hero h1 { font-size: 34px; margin: 18px 0 10px; }
.login-hero > p { color: var(--text-2); font-size: 16px; max-width: 420px; }
.hero-points { list-style: none; padding: 0; margin: 26px 0 0; display: grid; gap: 12px; }
.hero-points li { display: flex; align-items: center; gap: 10px; color: var(--text-2); }
.hero-points svg { color: var(--brand); }
.login-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 20px;
  padding: 28px; display: grid; gap: 14px; box-shadow: var(--shadow-lg);
}
.login-card h2 { font-size: 21px; }
.field { display: grid; gap: 6px; font-size: 13.5px; font-weight: 500; color: var(--text-2); }
@media (max-width: 760px) {
  .login-wrap { grid-template-columns: 1fr; gap: 28px; }
  .login-hero { text-align: center; }
  .login-hero .brand-mark { margin: 0 auto; }
  .login-hero h1 { font-size: 27px; }
  .login-hero > p { margin: 0 auto; font-size: 15px; }
  .hero-points { display: none; }
  .login-card { padding: 22px; }
}

/* ═════════ الهيكل ═════════ */
.shell { display: grid; grid-template-columns: 280px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 22px;
  padding: 20px 16px; background: var(--surface); border-inline-end: 1px solid var(--border);
  overflow-y: auto;
}
.main { min-width: 0; }
.content { padding: 24px 28px 40px; max-width: 1280px; margin: 0 auto; }

.nav { display: grid; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px;
  border: none; background: none; color: var(--text-2); font-weight: 500; text-align: start;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
a.nav-item { text-decoration: none; }
#memberText { white-space: pre-line; }
.live-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--bad); margin-inline-start: auto;
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--bad) 60%, transparent); animation: pulse 2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--bad) 55%, transparent); }
  70% { box-shadow: 0 0 0 7px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.side-section { flex: 1; min-height: 0; }
.side-title {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; font-weight: 600; color: var(--muted); padding: 0 6px 8px; letter-spacing: .02em;
}
.count { background: var(--surface-2); border-radius: 99px; padding: 0 8px; font-size: 11.5px; }
.device-list { display: grid; gap: 4px; }
.device-item {
  display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 12px;
  border: 1px solid transparent; background: none; text-align: start; width: 100%;
}
.device-item:hover { background: var(--surface-2); }
.device-item.selected { background: var(--surface-2); border-color: var(--border); }
.device-item .meta { min-width: 0; flex: 1; }
.device-item .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.device-item .sub { font-size: 12px; color: var(--muted); }

.side-footer {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding-top: 14px; border-top: 1px solid var(--border);
}
.user { display: flex; align-items: center; gap: 8px; min-width: 0; }
.user-email { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-actions { display: flex; gap: 6px; }

/* ═════════ أفاتار وحالة ═════════ */
.avatar {
  --h: 160;
  display: grid; place-items: center; flex: none; width: 38px; height: 38px; border-radius: 11px;
  background: hsl(var(--h) 60% 50% / .16); color: hsl(var(--h) 65% 42%); font-weight: 700; position: relative;
}
:root[data-theme="dark"] .avatar { color: hsl(var(--h) 70% 68%); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .avatar { color: hsl(var(--h) 70% 68%); } }
.avatar.sm { width: 30px; height: 30px; border-radius: 9px; font-size: 13px; }
.avatar.lg { width: 54px; height: 54px; border-radius: 15px; font-size: 22px; }
.avatar .dot { position: absolute; bottom: -2px; left: -2px; border: 2px solid var(--surface); }

.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; display: inline-block; }
.dot.protected { background: var(--ok); }
.dot.stopped { background: var(--bad); }
.dot.offline { background: var(--off); }

.status-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: 99px;
  font-size: 12.5px; font-weight: 600;
}
.status-pill.protected { background: var(--ok-soft); color: var(--ok); }
.status-pill.stopped { background: var(--bad-soft); color: var(--bad); }
.status-pill.offline { background: var(--off-soft); color: var(--muted); }

.pill { background: var(--surface-2); color: var(--muted); border-radius: 99px; padding: 1px 10px; font-size: 12px; font-weight: 600; }

/* ═════════ رأس الصفحة ═════════ */
.page-head { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .title { font-size: 22px; font-weight: 700; }
.page-head .meta { color: var(--muted); font-size: 13px; margin-top: 2px; }
.page-head .actions { display: flex; gap: 6px; margin-inline-start: auto; flex-wrap: wrap; }

/* ═════════ إحصائيات ═════════ */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow); display: grid; gap: 4px;
}
.stat .label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; font-weight: 500; }
.stat .label svg { color: var(--c, var(--brand)); }
.stat .value { font-size: 27px; font-weight: 700; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.stat .sub { font-size: 12px; color: var(--muted); }

/* ═════════ أدوات ═════════ */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.scope { display: flex; align-items: center; gap: 10px; font-size: 13px; flex-wrap: wrap; }
.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; }
.segmented button {
  border: none; background: none; padding: 6px 14px; border-radius: 7px; font-size: 13px; font-weight: 500; color: var(--muted);
}
.segmented button.active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }

/* ═════════ لوحات ═════════ */
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); margin-bottom: 16px; min-width: 0;
}
.panel.flush { padding: 4px 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.panel-head .muted { font-size: 12.5px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-2 > .panel { margin-bottom: 0; }
.grid-2 + .panel { margin-top: 16px; }
.tab-body > .grid-2 { margin-bottom: 16px; }

.d-tabs {
  display: flex;
  gap: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 16px;
}
.d-tabs button {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  padding: 9px 10px;
  border-radius: 9px;
  cursor: pointer;
}
.d-tabs button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.dev-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.dev-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 14px;
  cursor: pointer;
  text-align: right;
  font: inherit;
}
.dev-card .body { flex: 1; min-width: 0; }
.dev-card .name { font-weight: 700; margin-bottom: 2px; }
.dev-card .sub { color: var(--muted); font-size: 13px; }

.empty-hint { color: var(--muted); font-size: 13.5px; padding: 18px 4px; text-align: center; }

/* ترتيب (أكتر المواقع/التطبيقات) */
.rank-list { display: grid; gap: 4px; }
.rank {
  display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; align-items: center; gap: 10px;
  padding: 7px 6px; border-radius: 10px;
}
.rank:hover { background: var(--surface-2); }
.rank .body { min-width: 0; display: grid; gap: 5px; }
.rank .top { display: flex; justify-content: space-between; gap: 8px; font-size: 13.5px; }
.rank .name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank .name.ltr { direction: ltr; text-align: right; }
.rank .num { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar { height: 5px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--brand-2), var(--brand)); }
.rank.blocked .bar > i { background: var(--bad); }

/* ═════════ السجل ═════════ */
.filters { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.search { position: relative; flex: 1; min-width: 220px; display: flex; align-items: center; }
.search svg { position: absolute; inset-inline-start: 12px; color: var(--muted); pointer-events: none; }
.search input { padding-inline-start: 38px; background: var(--surface); }
.filter-toggles { display: flex; gap: 8px; flex-wrap: wrap; }
.check {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--border); font-size: 13px; cursor: pointer; user-select: none;
}
.check input { width: 15px; height: 15px; accent-color: var(--brand); margin: 0; }

.log-list { display: grid; }
.log-row {
  display: grid; grid-template-columns: 36px minmax(0, 1fr) auto auto; align-items: center; gap: 12px;
  padding: 10px 16px; border-bottom: 1px solid var(--border);
}
.log-row:last-child { border-bottom: none; }
.log-row.fresh { background: var(--fresh); }
.panel:not(.flush) .log-row { padding-inline: 4px; }
.log-row .site { min-width: 0; }
.log-row .domain {
  direction: ltr; text-align: right; font-weight: 500; font-size: 14px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.log-row .detail { font-size: 12.5px; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; }
.log-row .detail .sep { opacity: .5; }
.site-icon {
  --h: 160; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: hsl(var(--h) 55% 50% / .13); color: hsl(var(--h) 60% 42%); font-weight: 700; font-size: 14px; text-transform: uppercase;
}
:root[data-theme="dark"] .site-icon { color: hsl(var(--h) 65% 68%); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .site-icon { color: hsl(var(--h) 65% 68%); } }
.badge { padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.blocked { background: var(--bad-soft); color: var(--bad); }
.badge.allowed { background: var(--ok-soft); color: var(--ok); }

/* السجل متجمّع بالتطبيق */
.app-group { border-bottom: 1px solid var(--border); }
.app-group:last-child { border-bottom: none; }
.group-head {
  display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; align-items: start; gap: 12px;
  padding: 12px 16px; transition: background .6s;
}
.group-head.fresh { background: var(--fresh); }
.group-head > .btn { margin-top: 4px; }
.group-head .site-icon.app { border-radius: 50%; }
.group-head .meta { min-width: 0; }
.group-head .name {
  font-weight: 600; font-size: 14.5px; display: flex; align-items: center; gap: 8px; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.group-head .sub { font-size: 12.5px; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; margin-top: 1px; }
.group-head .sub .sep { opacity: .5; }
.group-head .sub .bad { color: var(--bad); font-weight: 600; }
.toggle {
  display: inline-flex; align-items: center; gap: 3px; margin-top: 4px; padding: 2px 0;
  border: none; background: none; color: var(--brand); font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.toggle svg { transition: transform .2s; }
.app-group.open .toggle svg { transform: rotate(180deg); }
.group-body { background: var(--surface-2); border-top: 1px solid var(--border); }
.group-body .log-row { padding-inline-start: 64px; }
.net-details { border-top: 1px dashed var(--border); }
.net-details summary {
  cursor: pointer; padding: 10px 16px 10px 64px; color: var(--muted);
  font-size: 12.5px; font-weight: 600; list-style: none;
}
.net-details summary::-webkit-details-marker { display: none; }
.net-details summary::before { content: "▸"; margin-inline-end: 6px; }
.net-details[open] summary::before { content: "▾"; }
.blocked-apps { margin-top: 16px; }
.app-row .where { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ═════════ القواعد ═════════ */
.pause-panel { display: flex; align-items: center; gap: 14px; }
.pause-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--bad-soft); color: var(--bad); flex: none; }
.pause-panel.on { border-color: color-mix(in srgb, var(--bad) 45%, var(--border)); background: color-mix(in srgb, var(--bad-soft) 55%, var(--surface)); }

.switch {
  --on: var(--brand);
  width: 48px; height: 28px; border-radius: 99px; border: none; padding: 3px; flex: none;
  background: var(--border); transition: background .2s; position: relative;
}
.switch.danger { --on: var(--bad); }
.switch span {
  position: absolute; top: 3px; right: 3px; /* مقفول = يمين، مفتوح = شمال (اتجاه عربي) */
  width: 22px; height: 22px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .2s;
}
.switch[aria-checked="true"] { background: var(--on); }
.switch[aria-checked="true"] span { transform: translateX(-20px); }

.add-row { display: flex; gap: 8px; margin-bottom: 14px; }
.add-row input { text-align: left; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 4px 6px 4px 12px; border-radius: 99px;
  background: var(--surface-2); border: 1px solid var(--border); direction: ltr; font-size: 13px; font-weight: 500;
}
.chip button { border: none; background: none; color: var(--muted); display: grid; place-items: center; padding: 2px; border-radius: 50%; }
.chip button:hover { color: var(--bad); background: var(--bad-soft); }

/* ═════════ تطبيقات جاهزة ═════════ */
.preset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.preset {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px; margin: 0;
  transition: border-color .2s, background .2s;
}
.preset .tile {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 22px; flex: none;
  background: color-mix(in srgb, var(--c) 16%, transparent);
}
.preset .name { font-weight: 600; }
.preset .sub { font-size: 12.5px; color: var(--muted); }
.preset.on { border-color: color-mix(in srgb, var(--bad) 40%, var(--border)); }
.preset.on .sub { color: var(--bad); font-weight: 500; }
.note { margin-top: 16px; }
.section-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.installed { margin-top: 20px; }
.installed .search { margin-bottom: 10px; }
.installed-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 4px 16px; }
.app-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-radius: 10px; min-width: 0;
}
.app-row:hover { background: var(--surface-2); }
.app-row .meta { flex: 1; min-width: 0; }
.app-row .name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-row .pkg { font-size: 11.5px; color: var(--muted); direction: ltr; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-row.on .name { color: var(--bad); }
.log-row .site-icon.app { border-radius: 50%; }
.alert.warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }

/* ═════════ تنبيهات ═════════ */
#alerts { display: grid; gap: 10px; }
#alerts:not(:empty) { margin-bottom: 18px; }
.alert {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 12px;
  background: var(--bad-soft); color: var(--bad); font-weight: 600; font-size: 14px;
  border: 1px solid color-mix(in srgb, var(--bad) 30%, transparent);
}
.alert .btn { margin-inline-start: auto; }

/* ═════════ لسه مفيش أجهزة ═════════ */
.empty {
  max-width: 560px; margin: 40px auto; text-align: center; background: var(--surface);
  border: 1px solid var(--border); border-radius: 20px; padding: 36px 28px; box-shadow: var(--shadow);
}
.empty-icon {
  width: 72px; height: 72px; margin: 0 auto 16px; border-radius: 20px; display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand);
}
.empty h2 { font-size: 22px; margin-bottom: 6px; }
.steps { text-align: start; margin: 24px 0 0; padding: 0; list-style: none; counter-reset: s; display: grid; gap: 12px; }
.steps li { counter-increment: s; display: grid; grid-template-columns: 28px 1fr; gap: 12px; color: var(--text-2); }
.steps li::before {
  content: counter(s); width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--brand); color: var(--on-brand); font-weight: 700; font-size: 13px;
}
.steps b { color: var(--text); }

/* ═════════ نافذة التأكيد ═════════ */
.modal {
  position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px;
  background: rgba(5, 10, 9, .55); backdrop-filter: blur(4px); animation: fade .15s;
}
.modal-card {
  width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; padding: 22px; display: grid; gap: 12px; box-shadow: var(--shadow-lg); animation: rise .18s;
}
.modal-card h3 { font-size: 17px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px) scale(.98); } }

/* ═════════ رسائل صغيرة ═════════ */
.toasts {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 45;
  display: grid; gap: 8px; width: max-content; max-width: calc(100vw - 32px);
}
.toast {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px 11px 16px; border-radius: 12px;
  background: var(--text); color: var(--bg); font-size: 14px; font-weight: 500; box-shadow: var(--shadow-lg);
  animation: rise .2s;
}
.toast button { border: none; background: none; color: var(--brand); font-weight: 700; display: inline-flex; gap: 4px; align-items: center; padding: 2px 4px; }
:root:not([data-theme="dark"]) .toast button { color: #6ee7b7; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .toast button { color: var(--brand-soft); } }
:root[data-theme="dark"] .toast button { color: var(--brand-soft); }

/* ═════════ الموبايل ═════════ */
.mobile-bar, .device-chips, .bottom-nav { display: none; }

@media (max-width: 1150px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 960px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .mobile-bar {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top));
    background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20;
  }
  .mobile-bar .brand-name { font-size: 15px; }
  .mobile-bar .icon-btn { width: 34px; height: 34px; }
  .device-chips {
    display: flex; gap: 8px; overflow-x: auto; padding: 12px 16px; scrollbar-width: none;
    background: var(--surface); border-bottom: 1px solid var(--border);
  }
  .device-chips::-webkit-scrollbar { display: none; }
  .device-chip {
    display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 8px; border-radius: 99px; flex: none;
    border: 1px solid var(--border); background: var(--surface); font-weight: 600; font-size: 13.5px; white-space: nowrap;
  }
  .device-chip.selected { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); }
  .content { padding: 16px 16px calc(92px + env(safe-area-inset-bottom)); }
  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; inset-inline: 0; z-index: 20;
    background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(12px);
    border-top: 1px solid var(--border); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .bottom-nav button {
    display: grid; justify-items: center; gap: 2px; border: none; background: none; color: var(--muted);
    font-size: 11.5px; font-weight: 500; padding: 6px 2px; border-radius: 10px; white-space: nowrap;
  }
  .bottom-nav button.active { color: var(--brand); font-weight: 600; }
  .toasts { bottom: calc(84px + env(safe-area-inset-bottom)); }
  .page-head .title { font-size: 19px; }
  .avatar.lg { width: 46px; height: 46px; font-size: 19px; }
}

@media (max-width: 560px) {
  .stats { gap: 10px; margin-bottom: 16px; }
  .stat { padding: 12px 14px; }
  .stat .value { font-size: 22px; }
  .stat .sub { display: none; }
  .panel { padding: 14px; }
  .log-row { grid-template-columns: 32px minmax(0, 1fr) auto; gap: 10px; padding: 10px 12px; }
  .log-row .badge { display: none; }
  .log-row .site-icon { width: 32px; height: 32px; }
  .group-head { padding: 12px; gap: 10px; grid-template-columns: 32px minmax(0, 1fr) auto; }
  .group-head .site-icon { width: 32px; height: 32px; }
  .group-body .log-row { padding-inline-start: 22px; }
  .page-head { gap: 12px; }
  .page-head .actions { margin-inline-start: 0; width: 100%; }
  .page-head .actions .btn { flex: 1; }
  .scope { width: 100%; justify-content: space-between; }
  .filters .search { min-width: 100%; }
  .empty { padding: 28px 18px; margin: 16px auto; }
  .bottom-nav button { font-size: 10.5px; padding: 6px 1px; }
  .d-tabs { overflow-x: auto; scrollbar-width: none; }
  .d-tabs::-webkit-scrollbar { display: none; }
  .d-tabs button { flex: 0 0 auto; white-space: nowrap; padding: 8px 10px; font-size: 12.5px; }
  .page-head .meta { font-size: 12px; }
  .device-chips { padding: 10px 12px; }
  .content { padding-inline: 12px; }
}

/* ═════════ العائلة والأكواد ═════════ */

.linkish {
  background: none;
  border: 0;
  color: var(--brand);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  padding: 4px 8px;
}
.linkish:hover { text-decoration: underline; }
.login-switch {
  margin-top: 14px;
  text-align: center;
}

.stack { display: flex; flex-direction: column; gap: 10px; }

.family-head-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0 10px;
}
.family-name {
  font-size: 22px;
  font-weight: 700;
}

.pair-code {
  display: flex;
  justify-content: center;
  gap: 8px;
  font-size: 40px;
  font-weight: 700;
  letter-spacing: 0.35em;
  color: var(--text);
  direction: ltr;
  background: var(--surface-2);
  border: 1px dashed var(--brand);
  border-radius: 12px;
  padding: 12px 8px;
  margin: 10px 0;
  font-variant-numeric: tabular-nums;
}

.pair-claims { display: flex; flex-direction: column; gap: 8px; }
.pair-claim {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--brand-soft);
  border: 1px solid var(--brand);
  border-radius: 12px;
  padding: 10px 12px;
}
.pair-claim .who { font-weight: 700; }
