/* VYBE Admin — dark professional theme, gold accents, iPad-first.
   Layout law: landscape / wide = sidebar + content grid; portrait
   (<= 900px) = the nav becomes a horizontal tap strip under the top
   bar. Every interactive target is >= 44px. Tables always scroll
   inside their own card (.table-wrap), never the page. */
:root {
  --bg: #0b0b0e;
  --surface: #141419;
  --surface-2: #1b1b22;
  --line: #2a2a33;
  --text: #f2f2f5;
  --muted: #9a9aa6;
  --gold: #d4af37;
  --gold-soft: #f3d58d;
  --danger: #e5484d;
  --ok: #46a758;
  --radius: 14px;
  --topbar-h: 60px;
  --nav-w: 248px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "IBM Plex Sans Arabic", "Segoe UI Arabic", Tahoma, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 700; }
h2 { font-size: 24px; }
.muted { color: var(--muted); }
.pad { padding: 18px; }
.error-text { color: var(--danger); }

/* ---------- buttons: >= 44px touch targets ---------- */
.btn {
  min-height: 44px;
  padding: 10px 18px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.98); }
.btn-gold { background: linear-gradient(180deg, #e8c766, var(--gold)); color: #171204; border-color: #8a6d1f; font-weight: 700; }
.btn-ghost { background: transparent; }
.btn-danger { background: var(--danger); border-color: #8c2b30; color: #fff; font-weight: 700; }
.btn-ok { background: var(--ok); border-color: #2c6b3a; color: #fff; font-weight: 600; }
.btn-small { min-height: 44px; padding: 8px 14px; font-size: 14px; }
.btn-big { width: 100%; min-height: 52px; font-size: 17px; }
.btn[disabled] { opacity: 0.5; pointer-events: none; }

/* ---------- login ---------- */
.login-wrap {
  min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: radial-gradient(1200px 600px at 50% -10%, rgba(212,175,55,0.14), transparent 60%), var(--bg);
}
.login-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 36px 28px;
  text-align: center;
  display: flex; flex-direction: column; gap: 16px; align-items: stretch;
}
.login-mark { width: 96px; height: 96px; border-radius: 22px; margin: 0 auto; }
.login-card h1 { font-size: 28px; }

/* ---------- shell ---------- */
.shell { min-height: 100dvh; }
.topbar {
  height: var(--topbar-h);
  padding: env(safe-area-inset-top) 16px 0 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: rgba(11,11,14,0.92);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 30;
  backdrop-filter: blur(10px);
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 20px; font-weight: 800; letter-spacing: 0.4px; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; }
.brand-admin { color: var(--gold); }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.user-chip { color: var(--muted); font-size: 14px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main-nav { display: flex; gap: 8px; }
.nav-item {
  min-height: 48px;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: flex; align-items: center; gap: 10px;
  font-size: 16px; text-align: start;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}
.nav-item .nav-ico { font-size: 18px; width: 22px; text-align: center; }
.nav-item.is-active { background: var(--surface-2); color: var(--text); border-color: var(--line); }
.nav-item.is-active .nav-ico { color: var(--gold); }

.content { padding: 20px; max-width: 1200px; margin: 0 auto; width: 100%; }
.view-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.subhead { margin: 22px 0 10px; font-size: 18px; }

/* wide / landscape: sidebar layout */
@media (min-width: 901px) {
  .shell { display: grid; grid-template-columns: var(--nav-w) 1fr; grid-template-rows: var(--topbar-h) 1fr; }
  .topbar { grid-column: 1 / -1; }
  .main-nav {
    flex-direction: column;
    padding: 16px 12px;
    border-inline-end: 1px solid var(--line);
    align-content: start;
    position: sticky; top: var(--topbar-h);
    height: calc(100dvh - var(--topbar-h));
    overflow-y: auto;
  }
  .nav-item { width: 100%; }
  .content { padding: 26px 30px; }
}
/* portrait / narrow: nav = horizontal tap strip */
@media (max-width: 900px) {
  .main-nav {
    flex-direction: row;
    overflow-x: auto;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    scrollbar-width: none;
    position: sticky; top: var(--topbar-h); z-index: 20;
    background: rgba(11,11,14,0.92); backdrop-filter: blur(10px);
  }
  .main-nav::-webkit-scrollbar { display: none; }
  .user-chip { display: none; }
  .content { padding: 16px 12px 28px; }
}

/* ---------- cards / stats ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.stat-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}
.stat-card { padding: 20px; }
.stat-num { font-size: 34px; font-weight: 800; color: var(--gold-soft); line-height: 1.1; }
.stat-label { color: var(--muted); margin-top: 4px; }

/* ---------- tables: scroll inside the card only ---------- */
.table-card { overflow: hidden; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; min-width: 560px; }
.table th, .table td { padding: 13px 14px; text-align: start; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { color: var(--muted); font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: 0.4px; }
.table tr:last-child td { border-bottom: none; }
.table .row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: var(--surface-2); vertical-align: middle; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 13px; border: 1px solid var(--line); background: var(--surface-2); }
.pill.gold { color: var(--gold-soft); border-color: #8a6d1f; }
.pill.red { color: #ff9c9f; border-color: #8c2b30; }
.pill.green { color: #8fd6a4; border-color: #2c6b3a; }

/* ---------- users split ---------- */
.split { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 901px) { .split { grid-template-columns: 1.25fr 1fr; align-items: start; } }
.search-row { display: flex; gap: 10px; margin-bottom: 14px; }
.search-row input { flex: 1; }
input[type="text"], input[type="search"], select, textarea {
  min-height: 48px;
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  width: 100%;
}
textarea { width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold); outline-offset: 0; border-color: var(--gold); }

.detail-card { padding: 20px; }
.detail-head { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }
.detail-head .avatar { width: 64px; height: 64px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 12px 0; font-size: 15px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }
.action-group { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.action-group h4 { margin: 0; font-size: 15px; color: var(--gold-soft); }
.inline-row { display: flex; gap: 10px; flex-wrap: wrap; }
.inline-row select { flex: 1; min-width: 130px; width: auto; }
.inline-row .btn { flex: 0 0 auto; }

/* ---------- segmented ---------- */
.seg { display: flex; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 4px; overflow-x: auto; }
.seg-btn { min-height: 44px; padding: 8px 16px; border: none; border-radius: 9px; background: transparent; color: var(--muted); cursor: pointer; white-space: nowrap; }
.seg-btn.is-active { background: var(--surface-2); color: var(--text); }

/* ---------- forms ---------- */
.form-card { padding: 22px; display: flex; flex-direction: column; gap: 14px; max-width: 640px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field span { color: var(--muted); font-size: 14px; }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(0,0,0,0.66);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal {
  width: min(480px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 24px;
  display: flex; flex-direction: column; gap: 14px;
}
.modal h3 { font-size: 20px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }
.modal-actions .btn { min-width: 110px; }

/* ---------- toasts ---------- */
.toast-root {
  position: fixed; bottom: calc(18px + env(safe-area-inset-bottom)); inset-inline: 0;
  display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 80;
  pointer-events: none; padding: 0 16px;
}
.toast {
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text);
  padding: 13px 20px; border-radius: 12px; max-width: 560px; width: auto;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5); font-size: 15px;
}
.toast.ok { border-color: #2c6b3a; }
.toast.err { border-color: #8c2b30; }

[dir="rtl"] .table th, [dir="rtl"] .table td { text-align: right; }
