/* Maxott Panel — Dark / Glass / Neon Purple — يدعم RTL */
:root {
  --bg: #07040f;
  --bg-2: #120a24;
  --glass: rgba(255, 255, 255, .055);
  --glass-strong: rgba(255, 255, 255, .09);
  --line: rgba(168, 139, 250, .22);
  --text: #ece8ff;
  --muted: #a79fc4;
  --neon: #a855f7;
  --neon-2: #7c3aed;
  --neon-soft: #d8b4fe;
  --ok: #34d399;
  --warn: #fbbf24;
  --bad: #fb7185;
  --radius: 18px;
  --side-w: 272px;
  --font: system-ui, -apple-system, "Segoe UI", Tahoma, "Noto Sans Arabic", "Noto Naskh Arabic", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(900px 520px at 8% -10%, rgba(168, 85, 247, .30), transparent 60%),
    radial-gradient(800px 520px at 100% 108%, rgba(99, 102, 241, .22), transparent 60%),
    radial-gradient(500px 360px at 85% 8%, rgba(236, 72, 153, .10), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--neon-soft); text-decoration: none; }
a:hover { color: #fff; }
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: .2px; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.neon { color: var(--neon); text-shadow: 0 0 18px rgba(168, 85, 247, .7); }
.ltr { direction: ltr; unicode-bidi: embed; display: inline-block; }
.spacer { flex: 1; }

/* ---------- زجاج ---------- */
.glass {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  backdrop-filter: blur(18px) saturate(140%);
  box-shadow: 0 12px 44px rgba(0, 0, 0, .45), inset 0 1px 0 rgba(255, 255, 255, .06);
}

/* ---------- الأزرار والحقول ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .55rem;
  padding: .75rem 1.3rem; border-radius: 14px; border: 1px solid transparent;
  font: inherit; font-weight: 600; cursor: pointer; color: #fff;
  transition: transform .15s ease, box-shadow .2s ease, background .2s ease;
}
.btn.primary {
  background: linear-gradient(135deg, var(--neon) 0%, var(--neon-2) 100%);
  box-shadow: 0 8px 28px rgba(124, 58, 237, .45), 0 0 0 1px rgba(255, 255, 255, .08) inset;
}
.btn.primary:hover { transform: translateY(-1px); box-shadow: 0 12px 34px rgba(168, 85, 247, .55); }
.btn.ghost { background: var(--glass); border-color: var(--line); color: var(--text); }
.btn.ghost:hover { background: var(--glass-strong); }
.btn.block { width: 100%; }
.btn .ico { width: 1.15em; height: 1.15em; }
.icon-btn {
  display: none; width: 42px; height: 42px; border-radius: 12px; cursor: pointer;
  background: var(--glass); border: 1px solid var(--line); color: var(--text);
  align-items: center; justify-content: center;
}

.field { display: block; margin-bottom: 1rem; }
.field > span { display: block; margin-bottom: .4rem; font-size: .88rem; color: var(--muted); }
.field input {
  width: 100%; padding: .8rem 1rem; border-radius: 13px; font: inherit; color: var(--text);
  background: rgba(6, 3, 14, .55); border: 1px solid var(--line); outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.field input:focus { border-color: var(--neon); box-shadow: 0 0 0 3px rgba(168, 85, 247, .25), 0 0 22px rgba(168, 85, 247, .25); }

.alert { padding: .75rem 1rem; border-radius: 13px; margin-bottom: 1rem; font-size: .92rem; border: 1px solid; }
.alert.ok { background: rgba(52, 211, 153, .1); border-color: rgba(52, 211, 153, .4); color: #a7f3d0; }
.alert.bad { background: rgba(251, 113, 133, .1); border-color: rgba(251, 113, 133, .45); color: #fecdd3; }
.alert.warn { background: rgba(251, 191, 36, .1); border-color: rgba(251, 191, 36, .45); color: #fde68a; }

/* ---------- صفحات الدخول والأخطاء ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.auth-card { width: min(440px, 100%); padding: 2.2rem 2rem 1.6rem; }
.auth-card.center { text-align: center; }
.auth-brand { text-align: center; margin-bottom: 1.6rem; }
.auth-brand h1 { font-size: 1.9rem; margin: .7rem 0 .2rem; }
.auth-foot { margin-top: 1.4rem; display: flex; justify-content: center; }
.err-code { font-size: 4.5rem; font-weight: 800; color: var(--neon); text-shadow: 0 0 34px rgba(168, 85, 247, .7); line-height: 1; margin: 1rem 0 .4rem; }
.auth-card.center h1 { font-size: 1.4rem; margin-bottom: .5rem; }
.auth-card.center .btn { margin-top: 1.4rem; }
.logo { filter: drop-shadow(0 0 14px rgba(168, 85, 247, .55)); }

.langs { display: flex; gap: .4rem; flex-wrap: wrap; }
.chip { padding: .32rem .8rem; border-radius: 999px; font-size: .82rem; color: var(--muted); border: 1px solid var(--line); background: var(--glass); }
.chip:hover { color: #fff; }
.chip.on { color: #fff; border-color: var(--neon); background: rgba(168, 85, 247, .25); box-shadow: 0 0 16px rgba(168, 85, 247, .35); }

/* ---------- هيكل اللوحة ---------- */
.app { display: grid; grid-template-columns: var(--side-w) 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 1.2rem 1rem;
  background: linear-gradient(180deg, rgba(18, 10, 36, .88), rgba(10, 6, 22, .92));
  border-inline-end: 1px solid var(--line);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: .7rem; font-size: 1.15rem; font-weight: 600; padding: .2rem .5rem 1.2rem; }
.nav { display: flex; flex-direction: column; gap: .2rem; flex: 1; }
.nav-title { margin: 1rem .6rem .3rem; font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); opacity: .8; }
.nav a {
  display: flex; align-items: center; gap: .75rem; padding: .66rem .8rem; border-radius: 13px;
  color: var(--muted); border: 1px solid transparent; transition: all .18s ease;
}
.nav a .ico { width: 20px; height: 20px; flex: none; }
.nav a:hover { color: #fff; background: var(--glass); }
.nav a.on {
  color: #fff; background: linear-gradient(90deg, rgba(168, 85, 247, .28), rgba(168, 85, 247, .06));
  border-color: rgba(168, 85, 247, .4); box-shadow: 0 0 22px rgba(168, 85, 247, .18);
}
.pill { margin-inline-start: auto; font-style: normal; font-size: .68rem; padding: .1rem .5rem; border-radius: 999px; background: rgba(168, 85, 247, .18); color: var(--neon-soft); border: 1px solid rgba(168, 85, 247, .35); }
.pill.big { font-size: .85rem; padding: .25rem .9rem; margin: 0; }
.side-foot { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--line); display: grid; gap: .8rem; }
.who { display: flex; align-items: center; gap: .7rem; }
.avatar { width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center; font-weight: 700; background: linear-gradient(135deg, var(--neon), var(--neon-2)); box-shadow: 0 0 18px rgba(168, 85, 247, .5); }
.who-name { font-weight: 600; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: .8rem; z-index: 5; margin: .8rem 1.2rem 0; padding: .65rem 1rem; display: flex; align-items: center; gap: .9rem; }
.page-title { font-size: 1.15rem; }
.content { padding: 1.4rem 1.2rem 3rem; }
.welcome { margin: 0 0 1.2rem; color: var(--muted); }

.grid.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 1rem; margin-bottom: 1.2rem; }
.stat { padding: 1.1rem 1.2rem; }
.stat-head { display: flex; align-items: center; gap: .55rem; color: var(--muted); font-size: .88rem; }
.stat-head .ico { width: 19px; height: 19px; color: var(--neon-soft); }
.stat-value { font-size: 1.8rem; font-weight: 700; margin: .5rem 0 .6rem; }
.bar { height: 8px; border-radius: 999px; background: rgba(255, 255, 255, .08); overflow: hidden; margin-bottom: .5rem; }
.bar > i { display: block; height: 100%; width: var(--w, 0%); border-radius: 999px; background: linear-gradient(90deg, var(--neon-2), var(--neon)); box-shadow: 0 0 14px var(--neon); }

.card { padding: 1.2rem 1.3rem; }
.card.narrow { max-width: 520px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .8rem; }
.card-head h3 { font-size: 1.05rem; }
.link { font-size: .88rem; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: .65rem .7rem; text-align: start; border-bottom: 1px solid rgba(255, 255, 255, .06); white-space: nowrap; }
td:nth-child(4) { white-space: normal; }
th { color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; }
tr:last-child td { border-bottom: 0; }
.tag { padding: .12rem .6rem; border-radius: 8px; background: rgba(168, 85, 247, .16); color: var(--neon-soft); font-size: .8rem; }

.soon { text-align: center; padding: 3rem 1.5rem; display: grid; gap: .8rem; justify-items: center; }
.soon h3 { font-size: 1.5rem; }
.soon p { margin: 0; max-width: 520px; }

.scrim { display: none; }

/* ---------- الاستجابة للهاتف ---------- */
@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  .icon-btn { display: inline-flex; }
  .sidebar {
    position: fixed; inset-block: 0; inset-inline-start: 0; width: min(300px, 84vw); z-index: 30;
    transform: translateX(-105%); transition: transform .25s ease;
  }
  [dir="rtl"] .sidebar { transform: translateX(105%); }
  .side-open .sidebar { transform: none; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, .55); opacity: 0; pointer-events: none; transition: opacity .25s; }
  .side-open .scrim { opacity: 1; pointer-events: auto; }
  .topbar { margin: .6rem .6rem 0; }
  .content { padding: 1rem .6rem 2.5rem; }
  .langs { display: none; }
}
@media (max-width: 520px) {
  .auth-card { padding: 1.6rem 1.2rem 1.2rem; }
  .stat-value { font-size: 1.5rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- المرحلة 2: القوائم والنماذج ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: .8rem; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
input[type="search"], select, textarea, .field select, .field textarea {
  padding: .6rem .85rem; border-radius: 12px; font: inherit; color: var(--text);
  background: rgba(6, 3, 14, .55); border: 1px solid var(--line); outline: none;
}
select option { background: #140d2b; color: var(--text); }
input[type="search"]:focus, select:focus, textarea:focus { border-color: var(--neon); box-shadow: 0 0 0 3px rgba(168, 85, 247, .22); }
.field select, .field textarea { width: 100%; }
.field textarea { resize: vertical; }
.field input[disabled] { opacity: .6; }
.btn.sm { padding: .42rem .85rem; font-size: .85rem; border-radius: 11px; gap: .4rem; }
.btn.danger { background: rgba(251, 113, 133, .12); border-color: rgba(251, 113, 133, .45); color: #fecdd3; }
.btn.danger:hover { background: rgba(251, 113, 133, .25); }
.actions { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }
.actions form { margin: 0; }
.actions.row { margin-top: 1.1rem; }
td.actions { white-space: nowrap; }
.badge { padding: .12rem .65rem; border-radius: 999px; font-size: .78rem; border: 1px solid; }
.badge.ok { color: #a7f3d0; background: rgba(52, 211, 153, .1); border-color: rgba(52, 211, 153, .4); }
.badge.off { color: #fecdd3; background: rgba(251, 113, 133, .1); border-color: rgba(251, 113, 133, .4); }
.pager { display: flex; gap: .8rem; align-items: center; justify-content: center; margin-top: 1rem; }
.empty { padding: 1.2rem .4rem; text-align: center; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 0 1rem; }
.check { display: flex; align-items: center; gap: .6rem; margin: .45rem 0; cursor: pointer; }
.check input { accent-color: var(--neon); width: 18px; height: 18px; }
.perms { border: 1px solid var(--line); border-radius: 14px; margin: .4rem 0 1rem; padding: .6rem 1rem; }
.perms legend { padding: 0 .5rem; color: var(--muted); font-size: .85rem; }
.split { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 1rem; margin-bottom: 1rem; align-items: start; }
.kv { display: flex; justify-content: space-between; gap: 1rem; padding: .5rem 0; border-bottom: 1px solid rgba(255, 255, 255, .06); }
.kv > span { color: var(--muted); }
.kv code { background: rgba(0, 0, 0, .35); padding: .15rem .6rem; border-radius: 8px; user-select: all; }
.balance { font-size: 2.6rem; font-weight: 800; margin: .2rem 0 1rem; color: var(--neon-soft); text-shadow: 0 0 24px rgba(168, 85, 247, .6); }
.amount { font-weight: 700; }
.amount.plus { color: var(--ok); }
.amount.minus { color: var(--bad); }
.creds { padding: 1.1rem 1.3rem; margin-bottom: 1rem; border-color: rgba(251, 191, 36, .5); }
.creds h3 { margin-bottom: .3rem; }
.stat-value a { color: inherit; }
