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

:root {
  --bg: #0b0d12;
  --bg-2: #10131a;
  --panel: #141821;
  --panel-2: #1a1f2b;
  --line: #242a37;
  --line-2: #2f3646;
  --text: #e7eaf0;
  --muted: #8b93a7;
  --faint: #5d6579;
  --accent: #d6334a;
  --accent-2: #7a1426;
  --accent-soft: rgba(214, 51, 74, 0.13);
  --green: #34d399;
  --green-soft: rgba(52, 211, 153, 0.12);
  --amber: #fbbf24;
  --amber-soft: rgba(251, 191, 36, 0.12);
  --red: #ff7a59;
  --red-soft: rgba(255, 122, 89, 0.12);
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
  --font: 'IBM Plex Sans Arabic', -apple-system, 'Segoe UI', Tahoma, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
body {
  background:
    radial-gradient(900px 600px at 85% -10%, rgba(214,51,74,.16), transparent 60%),
    radial-gradient(700px 500px at 0% 110%, rgba(122,20,38,.22), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}

a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.mono { font-family: var(--mono); font-size: 12.5px; direction: ltr; unicode-bidi: isolate; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* ---------------- Layout ---------------- */

.app {
  display: grid;
  grid-template-columns: 250px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: rgba(16, 19, 26, 0.78);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-left: 1px solid var(--line);
  padding: 22px 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 4px 10px 22px;
}
.brand-logo {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center;
  font-weight: 700; font-size: 17px; color: #fff;
  box-shadow: 0 6px 20px rgba(214, 51, 74, 0.4);
}
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: .2px; }
.brand-sub { font-size: 11.5px; color: var(--muted); margin-top: -2px; }

.nav-label {
  font-size: 11px; color: var(--faint);
  padding: 14px 12px 6px; letter-spacing: .5px;
}

.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  cursor: pointer;
  transition: background .15s, color .15s;
  border: 0; background: none; width: 100%; text-align: right;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .85; }
.nav-item:hover { background: var(--panel); color: var(--text); }
.nav-item.active {
  background: var(--accent-soft);
  color: #fff;
  box-shadow: inset -3px 0 0 var(--accent);
}
.nav-item .count {
  margin-inline-start: auto;
  font-size: 11px; color: var(--faint);
  font-family: var(--mono);
}

.sidebar-foot {
  margin-top: auto;
  padding: 12px;
  font-size: 11.5px;
  color: var(--faint);
  border-top: 1px solid var(--line);
}

.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 32px;
  border-bottom: 1px solid var(--line);
  background: rgba(11, 13, 18, 0.72);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: sticky; top: 0; z-index: 10;
}
.topbar h1 { font-size: 19px; margin: 0; font-weight: 600; }
.topbar .spacer { flex: 1; }

.content { padding: 28px 32px 60px; max-width: 1400px; width: 100%; }

/* ---------------- Controls ---------------- */

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-2);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  font-weight: 500; font-size: 13.5px;
  transition: border-color .15s, background .15s, transform .05s;
  white-space: nowrap;
}
.btn:hover { border-color: #3d4659; background: #202636; }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(135deg, #e03a52, #9d1830);
  border-color: transparent; color: #fff;
  box-shadow: 0 4px 14px rgba(214, 51, 74, 0.32);
}
.btn-primary:hover { background: linear-gradient(135deg, #ea4b62, #b01f3a); border-color: transparent; }
.btn-danger { color: var(--red); }
.btn-danger:hover { background: var(--red-soft); border-color: rgba(255,122,89,.35); }
.btn-danger-solid { background: #e8552f; border-color: transparent; color: #fff; }
.btn-danger-solid:hover { background: #f06a45; border-color: transparent; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--panel-2); color: var(--text); border-color: transparent; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-icon { padding: 6px; }

.input, .select, textarea.input {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.input { resize: vertical; min-height: 120px; font-family: var(--mono); font-size: 12.5px; direction: ltr; text-align: left; }
.input.ltr { direction: ltr; text-align: left; font-family: var(--mono); font-size: 13px; }

.search {
  position: relative;
  max-width: 320px; width: 100%;
}
.search svg { position: absolute; right: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--faint); }
.search .input { padding-right: 34px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-size: 13px; color: var(--muted); font-weight: 500; }
.field .hint { font-size: 12px; color: var(--faint); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.check { display: flex; align-items: center; gap: 9px; cursor: pointer; padding: 6px 0; }
.check input { accent-color: var(--accent); width: 16px; height: 16px; }

.dropzone {
  border: 1.5px dashed var(--line-2);
  border-radius: var(--radius-sm);
  padding: 20px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.dropzone.ok { border-color: var(--green); color: var(--green); background: var(--green-soft); border-style: solid; }

.account-switch {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px 6px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.account-switch .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); }
.account-switch select { background: transparent; border: 0; outline: none; cursor: pointer; padding-left: 4px; max-width: 220px; }
.account-switch select option { background: var(--panel); }

/* ---------------- Cards / Stats ---------------- */

.toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 18px;
}
.toolbar .spacer { flex: 1; }

.card {
  background: rgba(20, 24, 33, 0.86);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.card-head {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.card-head h3 { margin: 0; font-size: 15px; font-weight: 600; }
.card-body { padding: 18px 20px; }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}
.stat {
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: border-color .15s, transform .15s;
}
.stat:hover { border-color: var(--line-2); transform: translateY(-2px); }
.stat .label { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 8px; }
.stat .label svg { width: 17px; height: 17px; }
.stat .value { font-size: 32px; font-weight: 700; margin-top: 6px; font-family: var(--mono); letter-spacing: -1px; }
.stat .sub { font-size: 12px; color: var(--faint); margin-top: 2px; }
.stat::after {
  content: ''; position: absolute; inset-inline-end: -30px; top: -30px;
  width: 110px; height: 110px; border-radius: 50%;
  background: var(--glow, var(--accent)); opacity: .07; filter: blur(4px);
}
.stat.blue { --glow: var(--accent); }
.stat.violet { --glow: var(--accent-2); }
.stat.green { --glow: var(--green); }
.stat.amber { --glow: var(--amber); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.meter { height: 8px; background: var(--bg-2); border-radius: 99px; overflow: hidden; margin: 10px 0 6px; }
.meter > span { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .6s ease; }
.meter.warn > span { background: linear-gradient(90deg, var(--amber), #f97316); }
.meter.full > span { background: linear-gradient(90deg, #f97316, var(--red)); }

.list-row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}
.list-row:last-child { border-bottom: 0; }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .title { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------------- Table ---------------- */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: right; font-weight: 500; font-size: 12.5px; color: var(--muted);
  padding: 12px 16px; border-bottom: 1px solid var(--line);
  background: var(--panel); position: sticky; top: 0;
  white-space: nowrap;
}
td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: rgba(255, 255, 255, 0.02); }
td.actions { text-align: left; white-space: nowrap; }
td.actions .btn { margin-inline-start: 4px; }
.cell-title { font-weight: 500; }
.cell-sub { font-size: 12px; color: var(--faint); }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px;
  border-radius: 99px;
  font-size: 11.5px; font-weight: 500;
  background: var(--panel-2); color: var(--muted);
  border: 1px solid var(--line-2);
  white-space: nowrap;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.badge.green { color: var(--green); background: var(--green-soft); border-color: rgba(52,211,153,.25); }
.badge.amber { color: var(--amber); background: var(--amber-soft); border-color: rgba(251,191,36,.25); }
.badge.red { color: var(--red); background: var(--red-soft); border-color: rgba(255,122,89,.25); }
.badge.blue { color: var(--accent); background: var(--accent-soft); border-color: rgba(214,51,74,.3); }

.copy { cursor: pointer; border-bottom: 1px dashed transparent; }
.copy:hover { border-bottom-color: var(--faint); }

.empty {
  text-align: center; padding: 60px 20px; color: var(--muted);
}
.empty svg { width: 46px; height: 46px; color: var(--faint); margin-bottom: 10px; }
.empty h3 { color: var(--text); margin: 4px 0 6px; font-weight: 600; }

.skeleton {
  height: 14px; border-radius: 6px;
  background: linear-gradient(90deg, var(--panel-2) 25%, #222838 50%, var(--panel-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.error-box {
  background: var(--red-soft); color: #ffb39f;
  border: 1px solid rgba(255,122,89,.3);
  border-radius: var(--radius-sm);
  padding: 12px 14px; font-size: 13.5px;
}
.info-box {
  background: var(--accent-soft); color: #ffc2cb;
  border: 1px solid rgba(214,51,74,.3);
  border-radius: var(--radius-sm);
  padding: 12px 14px; font-size: 13px;
  margin-bottom: 16px;
}

/* ---------------- Accounts ---------------- */

.accounts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.account-card { padding: 20px; }
.account-card.active { border-color: rgba(214,51,74,.55); box-shadow: 0 0 0 1px rgba(214,51,74,.3); }
.account-card .top { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.avatar {
  width: 42px; height: 42px; border-radius: 11px;
  display: grid; place-items: center;
  font-weight: 700; font-size: 17px; color: #fff;
  background: linear-gradient(135deg, #334155, #1e293b);
  border: 1px solid var(--line-2);
}
.account-card.active .avatar { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; }
.kv { display: grid; grid-template-columns: 80px 1fr; gap: 6px 10px; font-size: 13px; margin-bottom: 16px; }
.kv dt { color: var(--faint); }
.kv dd { margin: 0; overflow: hidden; text-overflow: ellipsis; }
.account-card .foot { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------- Modal ---------------- */

.overlay {
  position: fixed; inset: 0;
  background: rgba(3, 5, 10, 0.7);
  backdrop-filter: blur(4px);
  display: grid; place-items: center;
  z-index: 100;
  padding: 20px;
  animation: fade .15s ease;
}
.modal {
  width: 100%; max-width: 520px;
  max-height: calc(100vh - 40px);
  display: flex; flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: 16px;
  box-shadow: var(--shadow);
  animation: pop .18s ease;
}
.modal.wide { max-width: 720px; }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; align-items: center; }
.modal-head h3 { margin: 0; font-size: 16px; font-weight: 600; flex: 1; }
.modal-body { padding: 20px 22px; overflow-y: auto; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-start; }
.modal .error-box { margin-bottom: 14px; }

.pick-list {
  max-height: 220px; overflow-y: auto;
  border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  background: var(--bg-2);
  padding: 4px 12px;
}
.pick-list .check { border-bottom: 1px solid var(--line); padding: 8px 0; }
.pick-list .check:last-child { border-bottom: 0; }

.results { max-height: 280px; overflow-y: auto; font-size: 13px; }
.results .list-row { padding: 7px 0; }

@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

/* ---------------- Toast ---------------- */

.toasts {
  position: fixed; bottom: 22px; left: 22px;
  display: flex; flex-direction: column; gap: 10px;
  z-index: 200;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  min-width: 260px; max-width: 420px;
  padding: 12px 16px;
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  border-radius: 12px;
  box-shadow: var(--shadow);
  animation: pop .2s ease;
  font-size: 13.5px;
}
.toast .ic { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; font-size: 12px; font-weight: 700; }
.toast.success .ic { background: var(--green-soft); color: var(--green); }
.toast.error .ic { background: var(--red-soft); color: var(--red); }
.toast.info .ic { background: var(--accent-soft); color: var(--accent); }
.toast.out { opacity: 0; transform: translateY(6px); transition: all .25s; }

.spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- Login ---------------- */

.login-page {
  min-height: 100vh;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  padding: 20px;
  position: relative; z-index: 1;
}
.login-page .site-foot { border: 0; margin: 0; }
.login-card { width: 100%; max-width: 380px; padding: 34px 30px; }
.login-card .brand { justify-content: center; padding-bottom: 6px; }
.login-card .brand-logo { width: 46px; height: 46px; font-size: 21px; border-radius: 13px; }
.login-card p.lead { text-align: center; color: var(--muted); margin: 0 0 24px; font-size: 13.5px; }
.login-card .btn { width: 100%; justify-content: center; padding: 11px; }

/* ---------------- Responsive ---------------- */

.list-row > svg { width: 18px; height: 18px; color: var(--muted); flex-shrink: 0; }
div.mono, .cell-sub.mono { text-align: right; }

.bundle-pattern { display: flex; align-items: center; gap: 6px; }
.bundle-pattern .input { flex: 1; min-width: 0; }
.pattern-var {
  padding: 8px 10px; border-radius: var(--radius-sm);
  background: var(--accent-soft); color: var(--accent);
  border: 1px dashed rgba(214,51,74,.5); font-weight: 600;
}

/* ---------------- المستخدمين والحماية ---------------- */

.user-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--muted);
  padding: 5px 10px; border: 1px solid var(--line); border-radius: 999px;
  max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-chip b { color: var(--text); font-weight: 600; direction: ltr; unicode-bidi: isolate; }


/* ---------------- خلفية النجوم ---------------- */

.stars-bg {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  z-index: 0; pointer-events: none;
}
.app { position: relative; z-index: 1; }
.overlay, .toasts { z-index: 300; }

/* ---------------- Team ID ---------------- */

.team-box {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 14px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  transition: border-color .2s, background .2s, box-shadow .2s;
}
.team-label { font-size: 12.5px; color: var(--muted); font-weight: 600; min-width: 62px; }
.team-value { flex: 1; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; min-width: 0; }
.team-box.ok { border-color: rgba(52,211,153,.45); background: var(--green-soft); box-shadow: 0 0 18px rgba(52,211,153,.12); }
.team-box.ok .team-id { font-size: 17px; font-weight: 600; color: var(--green); letter-spacing: 1.5px; }
.team-box.bad { border-color: rgba(255,122,89,.4); background: var(--red-soft); color: #ffb39f; }
.team-box.loading { border-color: rgba(214,51,74,.45); }

/* ---------------- الحقوق ---------------- */

.site-foot {
  margin-top: auto;
  padding: 18px 20px calc(18px + env(safe-area-inset-bottom));
  text-align: center;
  font-size: 12.5px;
  color: var(--faint);
  border-top: 1px solid var(--line);
}
.foot-name {
  font-weight: 700;
  color: #ff5a70;
  text-shadow: 0 0 10px rgba(255, 60, 90, .65);
  letter-spacing: .5px;
}

/* ---------------- قائمة التلفون ---------------- */

.menu-btn, .nav-close, .bottom-nav, .nav-backdrop { display: none; }

@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }

  /* القائمة الجانبية بتصير درج بيطلع من اليمين */
  .sidebar {
    position: fixed; top: 0; bottom: 0; right: 0;
    width: min(300px, 86vw); height: 100%;
    z-index: 250;
    background: rgba(14, 16, 23, 0.96);
    border-left: 1px solid var(--line-2);
    box-shadow: -20px 0 50px rgba(0,0,0,.5);
    transform: translateX(105%);
    transition: transform .25s ease;
    padding: calc(18px + env(safe-area-inset-top)) 14px calc(18px + env(safe-area-inset-bottom));
    gap: 2px;
  }
  body.nav-open .sidebar { transform: none; }
  .nav-backdrop {
    display: block;
    position: fixed; inset: 0; z-index: 240;
    background: rgba(3,5,10,.6);
    backdrop-filter: blur(3px);
    opacity: 0; pointer-events: none;
    transition: opacity .2s;
  }
  body.nav-open .nav-backdrop { opacity: 1; pointer-events: auto; }
  body.nav-open { overflow: hidden; }

  .brand { padding: 4px 6px 14px; }
  .nav-close { display: inline-flex; margin-inline-start: auto; }
  .nav-label {
    padding: 14px 10px 6px;
    margin-top: 4px;
    border-top: 1px solid var(--line);
    font-weight: 600; color: var(--muted);
  }
  .nav-label:first-of-type { border-top: 0; }
  .nav-item { padding: 12px 12px; font-size: 15px; }
  .nav-item svg { width: 20px; height: 20px; }

  /* الشريط العلوي */
  .menu-btn { display: inline-flex; }
  .topbar {
    flex-wrap: wrap;
    gap: 8px;
    padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  }
  .topbar h1 { font-size: 17px; }
  .user-chip { display: none !important; }
  .account-switch {
    order: 10;
    width: 100%;
    border-radius: 12px;
    padding: 8px 12px;
  }
  .account-switch select { max-width: none; flex: 1; font-size: 14px; }

  .content { padding: 18px 14px 24px; }
  .grid-2, .row { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 14px; }
  .stat .value { font-size: 26px; }
  .accounts-grid { grid-template-columns: 1fr; }
  .toolbar { gap: 8px; }
  .toolbar .search { max-width: none; flex: 1 1 100%; }
  .toolbar .muted { font-size: 13px; }
  .card-head { padding: 14px 16px; flex-wrap: wrap; }
  .card-body { padding: 14px 16px; }
  th, td { padding: 10px 12px; }
  td.actions .btn { margin: 2px 0; }

  .modal { max-height: calc(100vh - 24px); border-radius: 18px; }
  .overlay { padding: 12px; align-items: end; }
  .modal-foot { flex-wrap: wrap; }
  .modal-foot .btn { flex: 1; justify-content: center; }
  .input, .select { font-size: 16px; } /* يمنع iOS من التكبير */

  .toasts { left: 12px; right: 12px; bottom: calc(80px + env(safe-area-inset-bottom)); }
  .toast { min-width: 0; max-width: none; }

  /* شريط التنقل السفلي */
  .main { padding-bottom: calc(66px + env(safe-area-inset-bottom)); }
  .bottom-nav {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0;
    z-index: 200;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: rgba(12, 14, 20, 0.9);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--line);
  }
  .bn-item {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 6px 2px;
    border: 0; background: none; cursor: pointer;
    color: var(--faint); font-size: 11px;
    border-radius: 10px;
    transition: color .15s, background .15s;
  }
  .bn-item svg { width: 22px; height: 22px; }
  .bn-item.active { color: #fff; background: var(--accent-soft); }
  .bn-item.active svg { color: var(--accent); filter: drop-shadow(0 0 6px rgba(214,51,74,.7)); }
}

@media (max-width: 420px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .stat .value { font-size: 22px; }
  .kv { grid-template-columns: 70px 1fr; }
}

/* ---------------- تشخيص الأخطاء وفحص الحساب ---------------- */

.diag {
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  border: 1px solid var(--line-2);
  border-inline-start: 3px solid currentColor;
  background: var(--bg-2);
  width: 100%;
}
.diag.red { color: var(--red); background: var(--red-soft); border-color: rgba(255,122,89,.35); }
.diag.amber { color: var(--amber); background: var(--amber-soft); border-color: rgba(251,191,36,.3); }
.diag-title { font-weight: 700; font-size: 14px; }
.diag-hint { color: var(--text); font-size: 13px; margin-top: 4px; line-height: 1.7; }
.diag-apple { color: var(--muted); font-size: 12px; margin-top: 8px; word-break: break-word; }
.team-box.bad { padding: 8px; }
.team-box.bad .team-value { width: 100%; }

.verdict {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 16px; border-radius: 12px; margin-bottom: 14px;
  border: 1px solid var(--line-2);
}
.verdict-ic {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; font-weight: 800; font-size: 17px; color: #fff;
}
.verdict-title { font-weight: 700; font-size: 15.5px; }
.verdict-text { color: var(--muted); font-size: 13px; margin-top: 2px; }
.verdict.green { background: var(--green-soft); border-color: rgba(52,211,153,.35); }
.verdict.green .verdict-ic { background: var(--green); box-shadow: 0 0 14px rgba(52,211,153,.5); }
.verdict.amber { background: var(--amber-soft); border-color: rgba(251,191,36,.35); }
.verdict.amber .verdict-ic { background: #d99a10; box-shadow: 0 0 14px rgba(251,191,36,.45); }
.verdict.red { background: var(--red-soft); border-color: rgba(255,122,89,.4); }
.verdict.red .verdict-ic { background: #e8452f; box-shadow: 0 0 14px rgba(255,90,70,.55); }

.check-steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 6px; }
.step {
  padding: 10px; border-radius: 10px; text-align: center;
  background: var(--bg-2); border: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 2px; font-size: 12px;
}
.step b { font-weight: 600; font-size: 12px; color: var(--muted); }
.step span { font-weight: 700; font-size: 14px; }
.step.ok span { color: var(--green); }
.step.bad span { color: var(--red); }
.step.na span { color: var(--faint); }
.step.ok { border-color: rgba(52,211,153,.25); }
.step.bad { border-color: rgba(255,122,89,.35); }

.sec-h { margin: 18px 0 8px; font-size: 13px; color: var(--muted); font-weight: 600; }
.issues { display: flex; flex-direction: column; gap: 6px; }
.issue {
  padding: 9px 12px; border-radius: 9px; font-size: 13px;
  border-inline-start: 3px solid currentColor; background: var(--bg-2);
}
.issue.red { color: #ffb39f; background: var(--red-soft); }
.issue.amber { color: #fcd77a; background: var(--amber-soft); }
.list-row .badge + .badge, .list-row .badge + .muted { margin-inline-start: 4px; }

.health {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 8px 12px; margin: -2px 0 14px;
  border-radius: 10px; border: 1px solid var(--line-2);
  background: var(--bg-2); cursor: pointer; text-align: right;
  font-size: 13px; font-weight: 500;
}
.health .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.health-dot { width: 9px; height: 9px; border-radius: 50%; background: currentColor; box-shadow: 0 0 8px currentColor; flex-shrink: 0; }
.health.green { color: var(--green); border-color: rgba(52,211,153,.3); }
.health.amber { color: var(--amber); border-color: rgba(251,191,36,.3); }
.health.red { color: var(--red); border-color: rgba(255,122,89,.4); background: var(--red-soft); }
.health .cell-sub { color: var(--faint); }

@media (max-width: 960px) {
  .check-steps { grid-template-columns: 1fr 1fr; }
  .list-row { flex-wrap: wrap; }
}

/* ---------------- زر اللغة + الاتجاه الإنجليزي ---------------- */

.lang-btn { gap: 5px; padding: 6px 9px; }
.lang-btn svg { width: 17px; height: 17px; }
.lang-code { font-weight: 700; font-size: 12px; min-width: 16px; text-align: center; font-family: var(--font); }
.login-lang { position: fixed; top: calc(14px + env(safe-area-inset-top)); inset-inline-end: 14px; z-index: 5; }

[dir=ltr] body { font-family: 'IBM Plex Sans Arabic', -apple-system, 'Segoe UI', Roboto, sans-serif; }
[dir=ltr] .sidebar { border-left: 0; border-right: 1px solid var(--line); }
[dir=ltr] .nav-item { text-align: left; }
[dir=ltr] .nav-item.active { box-shadow: inset 3px 0 0 var(--accent); }
[dir=ltr] .search svg { right: auto; left: 11px; }
[dir=ltr] .search .input { padding-right: 12px; padding-left: 34px; }
[dir=ltr] .account-switch select { padding-left: 0; padding-right: 4px; }
[dir=ltr] th { text-align: left; }
[dir=ltr] td.actions { text-align: right; }
[dir=ltr] .toasts { left: auto; right: 22px; }
[dir=ltr] div.mono, [dir=ltr] .cell-sub.mono { text-align: left; }
[dir=ltr] .health { text-align: left; }

@media (max-width: 960px) {
  [dir=ltr] .sidebar {
    right: auto; left: 0;
    border-left: 0; border-right: 1px solid var(--line-2);
    box-shadow: 20px 0 50px rgba(0,0,0,.5);
    transform: translateX(-105%);
  }
  [dir=ltr] body.nav-open .sidebar { transform: none; }
  [dir=ltr] .toasts { left: 12px; right: 12px; }
}

@media (max-width: 960px) {
  .topbar .spacer { display: none; }
  .topbar h1 { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar .btn { flex-shrink: 0; }
  .lang-btn { padding: 6px 7px; }
}
