/* ============================================================
   Digital Market — Ultra Responsive Dark Luxury Theme
   100% Mobile & PC Tested Layout (Zero Collisions / Overlaps)
   ============================================================ */

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

:root {
  --bg:          #08070b;
  --sidebar-bg:  #0f0d15;
  --card-bg:     #0f0d15;
  --panel-bg:    #12101b;
  --border:      #1a1825;
  --border-h:    #2e2a42;
  --muted:       #808090;
  --desc:        #71717a;
  --red:         #dc2626;
  --red-h:       #b91c1c;
  --red-bright:  #ef4444;
  --danger:      #dc2626;
  --success:     #22c55e;
  --green:       #22c55e;
  --yellow:      #fbbf24;
  --purple:      #c084fc;
  --sidebar-w:   260px;
  --topbar-h:    56px;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; font-size: 16px; }

/* ===== Utility Classes ===== */
.d-none { display: none !important; }

body {
  font-family: 'Cairo', sans-serif;
  background: var(--bg);
  color: var(--muted);
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.5;
}

a { text-decoration: none; color: inherit; }

/* ===== Desktop Sidebar ===== */
aside {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-left: 1px solid var(--border);
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 0;
  overflow: hidden;
  position: sticky;
  top: 0;
  flex-shrink: 0;
  z-index: 60;
  transition: transform 0.3s ease;
}

aside > div:first-child {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex-shrink: 1;
}

aside .menu-items {
  overflow-y: auto;
  scrollbar-width: none;
  min-height: 0;
  flex: 1 1 auto;
}
aside .menu-items::-webkit-scrollbar { display: none; }

aside > div:last-child {
  margin-top: auto;
  flex-shrink: 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.brand-icon {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--red), var(--red-h));
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.menu-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: #3f3f50;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  margin-top: 28px;
  margin-bottom: 10px;
  padding-right: 14px;
}

.menu-items { list-style: none; }

.menu-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 14px;
  border-radius: 9px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 3px;
  transition: background 0.18s, color 0.18s;
  white-space: nowrap;
}

.menu-link i { width: 16px; text-align: center; font-size: 0.85rem; flex-shrink: 0; }

.menu-link:hover, .menu-link.active {
  background: rgba(220, 38, 38, 0.1);
  color: var(--red-bright);
}

.user-wallet-info {
  background: rgba(220, 38, 38, 0.07);
  border: 1px solid rgba(220, 38, 38, 0.18);
  padding: 12px 14px;
  border-radius: 10px;
  margin-bottom: 12px;
}

.btn-signin {
  background: var(--red);
  border: none;
  color: #fff;
  padding: 10px 14px;
  border-radius: 9px;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.88rem;
  transition: background 0.18s;
  white-space: nowrap;
}
.btn-signin:hover { background: var(--red-h); }

.btn-register {
  background: #181622;
  border: 1px solid #262335;
  color: #d4d4d8;
  padding: 10px 14px;
  border-radius: 9px;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.88rem;
  transition: background 0.18s, color 0.18s, border-color 0.18s;
  white-space: nowrap;
}
.btn-register:hover { background: #232032; color: #fff; border-color: #3b3752; }
.btn-register i { color: var(--red); }
/* مسافة بين زري "حساب جديد" و"تسجيل الدخول" (الزرارين جنب بعض inline-flex) */
#authBtn { margin-left: 16px; }

/* ===== Mobile Topbar & Drawer ===== */
.mobile-topbar {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-h);
  background: var(--sidebar-bg);
  border-bottom: 1px solid var(--border);
  z-index: 80;
  padding: 0 16px;
  align-items: center;
  justify-content: space-between;
}
.mobile-topbar .icon-btn,
.mobile-topbar a.icon-btn {
  background: transparent; border: none; cursor: pointer;
  font-size: 1.35rem; color: #d4d4d8; display: inline-flex; align-items: center; justify-content: center;
  padding: 6px 8px; border-radius: 8px; transition: background 0.2s; text-decoration: none;
}
.mobile-topbar .icon-btn:hover,
.mobile-topbar a.icon-btn:hover { background: #181524; color: #fff; }

.hamburger {
  width: 38px;
  height: 38px;
  background: #181524;
  border: 1px solid #262335;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  flex-shrink: 0;
}

.hamburger span {
  display: block;
  width: 18px;
  height: 2px;
  background: #d4d4d8;
  border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 59;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.visible { display: block; }

/* ===== Main Area ===== */
main {
  flex: 1;
  padding: 32px 36px;
  min-width: 0;
  max-width: 100%;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.header-title {
  color: #fff;
  font-size: 1.35rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-title i { color: var(--red); font-size: 1.15rem; flex-shrink: 0; }

/* ===== Button & Icon System (Zero Overlap Guaranteed) ===== */
.btn-buy, .btn-primary {
  background: var(--red);
  border: none;
  color: #fff;
  padding: 9px 18px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: background 0.18s ease, transform 0.1s ease;
  white-space: nowrap;
  line-height: 1.2;
}
.btn-buy:hover, .btn-primary:hover { background: var(--red-h); }
.btn-buy:active, .btn-primary:active { transform: scale(0.98); }

.btn-details, .btn-secondary {
  background: #181622;
  border: 1px solid #262335;
  color: #d4d4d8;
  padding: 9px 18px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
  white-space: nowrap;
  line-height: 1.2;
}
.btn-details:hover, .btn-secondary:hover { background: #232032; color: #fff; border-color: #3b3752; }

/* Ghost / Brand / Danger buttons for custom dialogs */
.btn-brand {
  background: var(--red);
  border: 1px solid var(--red);
  color: #fff;
  padding: 9px 18px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: background 0.18s ease, transform 0.12s ease;
  white-space: nowrap;
  line-height: 1.2;
}
.btn-brand:hover { background: var(--red-h); }
.btn-brand:active { transform: scale(0.98); }

.btn-ghost {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #a1a1aa;
  padding: 9px 18px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
  white-space: nowrap;
  line-height: 1.2;
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.06); color: #fff; border-color: rgba(255, 255, 255, 0.2); }

.btn-danger {
  background: var(--red);
  border: 1px solid var(--red);
  color: #fff;
  padding: 9px 18px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: background 0.18s ease, transform 0.12s ease;
  white-space: nowrap;
  line-height: 1.2;
}
.btn-danger:hover { background: var(--red-h); }
.btn-danger:active { transform: scale(0.98); }

.btn-buy i, .btn-primary i, .btn-details i, .btn-secondary i {
  font-size: 0.9rem;
  line-height: 1;
  flex-shrink: 0;
}

.btn-sm {
  padding: 6px 12px !important;
  font-size: 0.78rem !important;
  border-radius: 6px !important;
  gap: 5px !important;
}

.btn-lg {
  padding: 13px 26px !important;
  font-size: 0.95rem !important;
  border-radius: 10px !important;
  gap: 9px !important;
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  flex-shrink: 0;
}
.btn-icon i { font-size: 0.9rem; }

/* ===== Type Tabs (الكل / منتجات / خدمات) ===== */
.type-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 20px;
  border-bottom: 1px solid #262335;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.type-tab {
  background: transparent;
  border: none;
  color: #71717a;
  padding: 12px 20px;
  font-size: 0.88rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.18s ease, border-color 0.18s ease;
  white-space: nowrap;
  flex-shrink: 0;
}
.type-tab:hover {
  color: #d4d4d8;
}
.type-tab.active {
  color: #fff;
  border-bottom-color: var(--red);
}
.type-tab i {
  font-size: 0.9rem;
}
.tt-count {
  font-size: 0.72rem;
  background: #181622;
  color: #71717a;
  border: 1px solid #262335;
  padding: 2px 8px;
  border-radius: 99px;
  min-width: 22px;
  text-align: center;
  line-height: 1.3;
  transition: background 0.18s ease, color 0.18s ease;
}
.type-tab.active .tt-count {
  background: rgba(220, 38, 38, 0.15);
  color: #ef4444;
  border-color: rgba(220, 38, 38, 0.3);
}

/* ===== Category Filter Section (التفاف على أسطر بدل الشريط الأفقي) ===== */
.cats-section {
  margin-bottom: 24px;
}
.cats-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.cats-title {
  font-size: 0.9rem;
  font-weight: 800;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
}
.cats-title i { color: var(--red); }
.cats-count {
  font-size: 0.75rem;
  color: #71717a;
  background: #181622;
  border: 1px solid #262335;
  padding: 3px 10px;
  border-radius: 99px;
  white-space: nowrap;
}
.cats-search {
  margin-bottom: 10px;
}

#categoryPills {
  display: flex;
  flex-wrap: wrap; /* التفاف على أسطر — يتحمل أي عدد من الفئات */
  gap: 8px;
  align-items: center;
}
.cat-pill {
  background: #181622;
  border: 1px solid #262335;
  color: #d4d4d8;
  padding: 7px 14px;
  border-radius: 99px;
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease, transform 0.12s ease;
}
.cat-pill:hover {
  background: #232032;
  color: #fff;
  border-color: #3b3752;
  transform: translateY(-1px);
}
.cat-pill.active {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
  box-shadow: 0 4px 14px rgba(220, 38, 38, 0.35);
}
.cat-pill .cat-icon {
  font-size: 0.9rem;
  color: inherit;
  display: inline-flex;
  flex-shrink: 0;
}
.cat-pill.active .cat-icon { color: #fff; }

/* زرار متابعة الفئة — دائري صغير بأيقونة جرس (أنيق بنفس أسلوب زرار القلب على الكروت) */
.cat-follow-btn {
  min-width: 0;
  width: 30px;
  height: 30px;
  padding: 0;
  margin-inline-start: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 13, 21, 0.8);
  color: #a3a3a3;
  border: 1px solid #3f3f46;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.75rem;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease, transform 0.12s ease;
}
.cat-follow-btn:hover {
  border-color: #71717a;
  color: #fff;
  transform: scale(1.08);
}
.cat-follow-btn.following {
  background: #eab308;
  border-color: #eab308;
  color: #1c1917;
}
.cat-follow-btn.following:hover {
  background: #fbbf24;
  border-color: #fbbf24;
}

/* ===== Grid & Cards ===== */
.grid-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s, border-color 0.2s;
}

.card:hover { transform: translateY(-3px); border-color: var(--border-h); }

/* تمييز عرض معيّن (من زر قناة التسويق) بلون ذهبي عشان يبان من أول لحظة */
.card.highlight-gold {
  border: 2px solid #eab308;
  box-shadow: 0 0 0 3px rgba(234, 179, 8, 0.25), 0 0 24px rgba(234, 179, 8, 0.35);
  animation: goldPulse 1.6s ease-in-out infinite;
}
.card.highlight-gold .card-title { color: #fde68a; }
.card.highlight-gold .card-price { color: #fbbf24; }

@keyframes goldPulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(234, 179, 8, 0.25), 0 0 20px rgba(234, 179, 8, 0.35); }
  50%      { box-shadow: 0 0 0 4px rgba(234, 179, 8, 0.4),  0 0 32px rgba(234, 179, 8, 0.55); }
}

.card-preview {
  height: 155px;
  width: 100%;
  position: relative;
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  background-color: #0f0d15;
  padding: 14px;
}

.tag-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(15, 13, 21, 0.88);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(220, 38, 38, 0.4);
  color: var(--red-bright);
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}

.badge-instant { border-color: rgba(34,197,94,.4); color: #4ade80; }
.badge-service  { border-color: rgba(245,158,11,.4); color: var(--yellow); }
.badge-player   { border-color: rgba(168,85,247,.4); color: var(--purple); }

.card-body {
  padding: 18px;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.card-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.card-title  { color: #fff; font-weight: 700; font-size: 0.95rem; word-break: break-word; }
.card-price-wrap { display: flex; flex-direction: column; align-items: flex-end; flex-shrink: 0; }
.card-price  { color: var(--green); font-weight: 800; font-size: 0.95rem; direction: ltr; white-space: nowrap; }
.card-price-egp { color: #a3a3a3; font-weight: 700; font-size: 0.78rem; direction: ltr; white-space: nowrap; }
.card-desc   { font-size: 0.8rem; color: var(--desc); line-height: 1.5; margin-bottom: 16px; word-break: break-word; }
.card-meta   { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.card-meta .cm {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 0.72rem; font-weight: 600;
  color: var(--desc); background: rgba(109, 91, 208, .08);
  border: 1px solid rgba(109, 91, 208, .2);
  border-radius: 999px; padding: 3px 10px;
  line-height: 1.3; white-space: nowrap;
}
.card-meta .cm i { font-size: 0.65rem; color: var(--accent, #8b7cf6); }

/* ==== عدّاد مدة نشر العرض ==== */
.listing-countdown.cm {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 0.72rem; font-weight: 700;
  padding: 2px 7px; border-radius: 999px;
  border: 1px solid; line-height: 1.4; white-space: nowrap;
}
.listing-countdown.cd-ok   { border-color: rgba(34,197,94,.35); color: #4ade80; background: rgba(34,197,94,.08); }
.listing-countdown.cd-warn { border-color: rgba(245,158,11,.4);  color: var(--yellow); background: rgba(245,158,11,.08); }
.listing-countdown.cd-danger{ border-color: rgba(239,68,68,.45); color: #f87171; background: rgba(239,68,68,.1); }
.expired-card { opacity: .45; filter: grayscale(.6); pointer-events: none; }

.card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ===== Deal Cards (deals.html) ===== */
.deal-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: transform 0.2s, border-color 0.2s;
}
.deal-card:hover { transform: translateY(-2px); border-color: var(--border-h); }
.deal-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.deal-card-title {
  color: #fff;
  font-weight: 800;
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  word-break: break-word;
}
.deal-card-title i { color: var(--red); }
.deal-card-amt {
  color: var(--green);
  font-weight: 800;
  font-size: 1rem;
  direction: ltr;
  white-space: nowrap;
}
.deal-card-body {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 0.82rem;
  color: #a1a1aa;
}
.deal-card-body b { color: #fff; }
.deal-card-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.deal-card-open {
  background: rgba(220, 38, 38, 0.1);
  border: 1px solid rgba(220, 38, 38, 0.3);
  color: var(--red-bright);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.2s, color 0.2s;
}
.deal-card-open:hover { background: var(--red); color: #fff; }

/* Deal chat scroll container */
.chat-scroll {
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}
.chat-msg {
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

/* ===== Binance PIN Input ===== */
.binance-pin-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
}

.binance-pin-group {
  display: flex;
  gap: 8px;
  direction: ltr;
  justify-content: center;
  flex-wrap: nowrap;
  width: 100%;
  max-width: 360px;
}

.binance-pin-box {
  width: 46px;
  height: 52px;
  flex: 1 1 auto;
  min-width: 0;
  max-width: 52px;
  background: #181524;
  border: 1px solid #262335;
  border-radius: 99px;
  color: #fff;
  font-size: 1.4rem;
  font-weight: 800;
  text-align: center;
  font-family: monospace;
  transition: border-color 0.18s, background 0.18s;
}

.binance-pin-box:focus  { outline: none; border-color: var(--red); background: #1f1b2e; }
.binance-pin-box.filled { border-color: var(--red); }

/* ===== Modals ===== */
.modal-overlay {
  display: none !important;
  position: fixed;
  inset: 0;
  z-index: 120;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 16px;
}
.modal-overlay.active {
  display: flex !important;
  padding: 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
  /* flex-start يسمح بالوصول لبداية المودال لو طويل؛ margin auto يوسطه لو قصير */
  align-items: flex-start;
  justify-content: center;
}
.modal-overlay.active .modal {
  margin: auto 0;
}

.modal {
  width: min(500px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 28px 24px;
  background: linear-gradient(145deg, #13101c 0%, #0c0a12 100%);
  border: 1px solid rgba(220, 38, 38, 0.25);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7), 0 0 30px rgba(220, 38, 38, 0.08);
  border-radius: 20px;
  position: relative;
  animation: modalPop 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  -webkit-overflow-scrolling: touch;
}
@keyframes modalPop {
  0% { transform: scale(0.94) translateY(12px); opacity: 0; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}
.modal-xl { width: min(780px, 100%); }
.modal-sm { width: min(380px, 100%); }

/* نوافذ التقييم تفتح فوق كل النوافذ المفتوحة (مودال الصفقة / بروفايل الطرف الآخر) */
#reviewModal, #editReviewModal { z-index: 140; }

/* Fullscreen modal for deal chat */
.modal-overlay:has(.modal-fullscreen) {
  padding: 0 !important;
  align-items: stretch !important;
  justify-content: stretch !important;
  overflow-y: auto;
}
.modal-fullscreen {
  width: 100% !important;
  max-width: 100% !important;
  /* 100dvh يحل مشكلة شريط المتصفح على الموبايل (الشريط يظهر ويختفي) */
  max-height: 100dvh;
  height: 100dvh;
  border-radius: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  display: flex;
  flex-direction: column;
  /* مساحة آمنة للملاحة على الأجهزة التي فيها Notch / Home Indicator */
  padding-top: env(safe-area-inset-top, 0);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.modal-overlay.active .modal-fullscreen {
  margin: 0;
}
.fullscreen-close {
  top: 16px !important;
  left: 16px !important;
  z-index: 10;
  width: 40px;
  height: 40px;
  font-size: 1.4rem;
  background: rgba(24, 21, 36, 0.9) !important;
  border: 1px solid rgba(255,255,255,0.1) !important;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
.fullscreen-close:hover {
  background: var(--red) !important;
  color: #fff !important;
  border-color: var(--red) !important;
}

/* Typing indicator */
.typing-indicator {
  display: none;
  align-items: center;
  gap: 8px;
  height: 28px;
  background: rgba(220, 38, 38, 0.08);
  border-top: 1px solid rgba(220, 38, 38, 0.15);
}
.typing-dots {
  display: flex;
  gap: 3px;
}
.typing-dots span {
  width: 6px;
  height: 6px;
  background: var(--red);
  border-radius: 50%;
  animation: typingBounce 1.2s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* شريط إدخال الشات: الإدخال يتمدّد والأزرار ثابتة العرض، لا تلتهم المساحة */
.deal-chat-input-bar {
  align-items: stretch;
}
.deal-chat-input-bar #chatInput {
  flex: 1 1 auto !important;
  width: auto !important;
  min-width: 0 !important;
}
.deal-chat-input-bar .chat-attach-btn,
.deal-chat-input-bar .chat-send-btn {
  flex: 0 0 auto !important;
}

.modal-header-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: rgba(220, 38, 38, 0.12);
  border: 1px solid rgba(220, 38, 38, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  color: var(--red);
  margin-bottom: 14px;
}

.modal h2 {
  font-size: 1.25rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 4px;
}

.modal-sub {
  font-size: 0.85rem;
  color: #71717a;
  margin-bottom: 20px;
  line-height: 1.5;
}

.glass-panel {
  background: linear-gradient(135deg, rgba(24, 21, 36, 0.9) 0%, rgba(15, 13, 21, 0.95) 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-right: 3px solid var(--red);
  border-radius: 16px;
  padding: 22px;
  margin-bottom: 22px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: all 0.25s ease;
}
.glass-panel:hover {
  border-color: rgba(220, 38, 38, 0.4);
  box-shadow: 0 12px 35px rgba(220, 38, 38, 0.1);
}

.modal .form-group {
  margin-bottom: 14px;
}

#authSubmitBtn {
  margin-top: 6px;
}

.field {
  width: 100%; min-height: 44px; padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.1); background: #13101c; color: #fff;
  border-radius: 10px; font-size: 0.88rem; transition: all 0.2s ease;
  font-family: 'Cairo', sans-serif;
}
.field:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.2);
  background: #181424;
}

.modal .close-x {
  position: absolute;
  top: 14px;
  left: 14px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-size: 1.2rem;
  color: #71717a;
  background: #181524;
  cursor: pointer;
  border: none;
}
.modal .close-x:hover { color: #fff; background: var(--red); }

/* ===== USDT Deposit Callout (modal) ===== */
.dep-callout {
  background: linear-gradient(160deg, rgba(13, 26, 16, 0.95) 0%, rgba(10, 9, 14, 0.98) 100%);
  border: 1px solid rgba(34, 197, 94, 0.28);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.dep-coin {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  font-weight: 800;
  font-size: 0.95rem;
}
.dep-coin > i { color: var(--green); font-size: 1.05rem; }
.dep-net {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.35);
  color: #4ade80;
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.4px;
  padding: 2px 8px;
  border-radius: 99px;
}
.dep-note {
  font-size: 0.82rem;
  color: #a1a1aa;
  line-height: 1.6;
  margin: 8px 0 12px;
}
.dep-note b { color: #4ade80; }
.dep-lbl {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 7px;
}
.dep-addr {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(34, 197, 94, 0.22);
  border-radius: 10px;
  padding: 7px 7px 7px 12px;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.dep-addr:focus-within { border-color: rgba(34, 197, 94, 0.5); background: rgba(34, 197, 94, 0.04); }
.dep-addr-id {
  flex: 1;
  min-width: 0;
  direction: ltr;
  text-align: center;
  font-weight: 800;
  color: #4ade80;
  font-size: 1rem;
  letter-spacing: 1px;
  font-family: 'Courier New', monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dep-addr-id.unavailable { color: #f87171; }
.dep-copy {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(34, 197, 94, 0.14);
  border: 1px solid rgba(34, 197, 94, 0.35);
  color: #4ade80;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: 'Cairo', sans-serif;
}
.dep-copy:hover { background: rgba(34, 197, 94, 0.25); color: #fff; }
.dep-copy:active { transform: scale(0.96); }
.dep-warn {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  margin-top: 10px;
  font-size: 0.75rem;
  color: var(--yellow);
  background: rgba(251, 191, 36, 0.08);
  border: 1px solid rgba(251, 191, 36, 0.22);
  padding: 7px 10px;
  border-radius: 8px;
  line-height: 1.55;
}
.dep-warn i { margin-top: 2px; flex-shrink: 0; }

/* ===== Custom Scrollbars (موحد لكل السكرولات) ===== */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(220, 38, 38, 0.5) rgba(24, 21, 36, 0.6);
}
*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
*::-webkit-scrollbar-track {
  background: rgba(24, 21, 36, 0.6);
  border-radius: 8px;
}
*::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(220, 38, 38, 0.55), rgba(139, 124, 246, 0.55));
  border-radius: 8px;
  border: 2px solid rgba(24, 21, 36, 0.6);
}
*::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, rgba(220, 38, 38, 0.8), rgba(139, 124, 246, 0.8));
}
*::-webkit-scrollbar-corner { background: transparent; }

/* سكرول أنعم وأجمل داخل المودال */
.modal {
  scrollbar-width: thin;
  scrollbar-color: rgba(220, 38, 38, 0.6) transparent;
}
.modal::-webkit-scrollbar { width: 6px; }
.modal::-webkit-scrollbar-track { background: transparent; }
.modal::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(220, 38, 38, 0.7), rgba(139, 124, 246, 0.6));
  border: none;
}

/* ===== Custom Dialogs (confirm / prompt / alert) ===== */
.dm-dialog-overlay {
  position: fixed; inset: 0; z-index: 200;
  display: none !important;
  align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.dm-dialog-overlay.active { display: flex !important; }

.dm-dialog {
  width: min(430px, 100%);
  background: linear-gradient(145deg, #16121f 0%, #0d0b14 100%);
  border: 1px solid rgba(220, 38, 38, 0.3);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.75), 0 0 40px rgba(220, 38, 38, 0.08);
  border-radius: 18px;
  padding: 26px 24px 22px;
  animation: modalPop 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  margin: auto;
}

.dm-dialog-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.dm-dialog-ico {
  flex-shrink: 0;
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px; font-size: 1.15rem;
  background: rgba(220, 38, 38, 0.1);
  border: 1px solid rgba(220, 38, 38, 0.28);
  color: var(--red);
}
.dm-dialog-context .dm-dialog-ico { background: rgba(139, 124, 246, .1); border-color: rgba(139, 124, 246, .3); color: #8b7cf6; }
.dm-dialog-prompt-wrap { width: 100%; margin-bottom: 18px; }
.dm-dialog-context .dm-dialog-in {
  width: 100%; min-height: 48px; padding: 12px 16px; box-sizing: border-box;
  border: 1px solid rgba(255, 255, 255, 0.16); background: #13101c; color: #fff;
  border-radius: 10px; font-size: 0.95rem; outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.dm-dialog-context .dm-dialog-in:focus { border-color: #8b7cf6; box-shadow: 0 0 0 3px rgba(139, 124, 246, .25); }

.dm-dialog-title { font-size: 1.05rem; font-weight: 800; color: #fff; margin: 0; }
.dm-dialog-msg { font-size: 0.88rem; color: #a1a1aa; line-height: 1.6; margin: 0 0 20px; white-space: pre-wrap; }
.dm-dialog-msg div, .dm-dialog-msg table, .dm-dialog-msg img, .dm-dialog-msg a, .dm-dialog-msg span, .dm-dialog-msg p { white-space: normal; }
.dm-dialog-actions { display: flex; gap: 10px; justify-content: flex-end; }
.dm-dialog-actions .btn { min-width: 100px; }

/* ===== Wide Dialog for Dispute Details ===== */
.dm-dialog-overlay.wide .dm-dialog { width: min(900px, 100%); max-height: 92vh; }
.dm-dialog-overlay.wide .dm-dialog-msg { max-height: 70vh; overflow-y: auto; }
.dm-dialog-overlay.wide .dm-dialog-actions { justify-content: flex-end; }

/* ===== Sensitive Action Verification (2-factor instant) ===== */
.dm-sec-actions { flex-direction: column; align-items: stretch; gap: 12px; }
.dm-sec-form { display: flex; flex-direction: column; gap: 10px; margin-bottom: 4px; }
.dm-sec-field label, .dm-sec-form label { display: block; font-size: 0.8rem; color: #a1a1aa; margin-bottom: 6px; font-weight: 600; }
.dm-sec-channel-btn { flex: 1; min-width: 120px; }
.dm-sec-channel-btn.active { border-color: #8b7cf6; background: rgba(139, 124, 246, 0.12); color: #fff; }
.dm-sec-send-note { font-size: 0.78rem; color: #22c55e; margin-top: 4px; display: none; }
.dm-sec-2fa-hint { font-size: 0.8rem; color: #fbbf24; background: rgba(251, 191, 36, 0.08); border: 1px solid rgba(251, 191, 36, 0.25); padding: 8px 10px; border-radius: 8px; margin-bottom: 6px; }

/* ===== Admin Specific UI ===== */
.admin-header-nav {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
  -webkit-overflow-scrolling: touch;
}

.admin-nav-item {
  background: #12101b;
  border: 1px solid var(--border);
  color: var(--desc);
  padding: 9px 16px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.83rem;
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 7px;
  transition: all 0.2s ease;
  flex-shrink: 0;
}
.admin-nav-item i { font-size: 0.85rem; flex-shrink: 0; }
.admin-nav-item:hover { background: #1a1727; color: #fff; border-color: #2c283f; }
.admin-nav-item.active { background: var(--red); color: #fff; border-color: var(--red); }

.admin-sec-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}
.admin-sec-head h3 { color: #fff; font-size: 1.05rem; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.admin-sec-head h3 i { color: var(--red); flex-shrink: 0; }

.admin-sub-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 6px;
  flex-wrap: nowrap;
}
.admin-sub-tabs::-webkit-scrollbar { height: 4px; }
.admin-sub-tabs::-webkit-scrollbar-thumb { background: rgba(220, 38, 38, 0.4); border-radius: 4px; }
.admin-sub-tabs button, .admin-sub-tabs a { flex-shrink: 0 !important; white-space: nowrap !important; }

.badge-status {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
.badge-status.green { background: rgba(34,197,94,0.12); color: #4ade80; border: 1px solid rgba(34,197,94,0.3); }
.badge-status.red   { background: rgba(220,38,38,0.12); color: #f87171; border: 1px solid rgba(220,38,38,0.3); }
.badge-status.gold  { background: rgba(251,191,36,0.12); color: #fbbf24; border: 1px solid rgba(251,191,36,0.3); }

/* Admin pending request cards (deposits / withdrawals) */
.pending-req-count {
  font-size: 0.85rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.admin-req-card {
  background: #181524;
  border-radius: 12px;
  margin-bottom: 16px;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(0,0,0,0.18);
}
.admin-req-card + .admin-req-card {
  margin-top: 20px;
}

.admin-req-no {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 800;
}
.admin-req-no b {
  font-size: 1.1rem;
  margin-right: 2px;
}

.admin-req-body {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  flex-wrap: wrap;
  padding: 14px 16px 16px;
  line-height: 1.9;
}

.admin-req-actions {
  display: flex;
  flex-direction: column;
  gap: 9px;
  align-items: stretch;
  min-width: 200px;
}
.admin-req-actions .btn-buy,
.admin-req-actions .btn-details,
.admin-req-actions .btn-reject {
  width: 100%;
  justify-content: center;
}

.btn-reject {
  background: rgba(220,38,38,0.1);
  border: 1px solid rgba(220,38,38,0.45);
  color: #f87171;
  padding: 13px 26px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease, transform 0.1s ease;
  white-space: nowrap;
  line-height: 1.2;
}
.btn-reject:hover { background: rgba(220,38,38,0.2); color: #fff; border-color: #f87171; }
.btn-reject:active { transform: scale(0.98); }

.admin-req-card button[data-v] { transition: all 0.15s ease; }
.admin-req-card button[data-v]:hover {
  background: rgba(167,139,250,0.15) !important;
  border-color: #a78bfa !important;
  color: #fff !important;
}

@media (max-width: 640px) {
  .admin-req-actions {
    width: 100%;
    min-width: 0;
  }
}

/* Table Wrapper */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 12px; border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 0.84rem; white-space: nowrap; }
th, td { padding: 11px 13px; text-align: right; border-bottom: 1px solid var(--border); }
th { background: #181524; color: #71717a; font-weight: 700; font-size: 0.78rem; text-transform: uppercase; }
td { background: #0f0d15; color: #d4d4d8; }
tr:last-child td { border-bottom: none; }

/* ===== Toast System (Fixed Position - Zero Page Shifting) ===== */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 380px;
  width: calc(100% - 48px);
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background: #181524;
  border: 1px solid #262335;
  border-right: 4px solid #3b82f6;
  border-radius: 12px;
  padding: 12px 16px;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  animation: toastSlideIn 0.3s ease forwards;
}

.toast.success { border-right-color: #22c55e; }
.toast.error   { border-right-color: #ef4444; }
.toast.info    { border-right-color: #3b82f6; }
.toast.staff   { border-right-color: #f59e0b; }

.toast .t-ico {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.toast .t-body {
  display: flex;
  flex-direction: column;
  font-size: 0.85rem;
  line-height: 1.4;
}

.toast .t-body strong { color: #fff; font-size: 0.88rem; }
.toast .t-body span { color: #d4d4d8; }

@keyframes toastSlideIn {
  0% { transform: translateY(20px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE MEDIA QUERIES (FULL MOBILE FIX)
═══════════════════════════════════════════════════════════════ */
@media (max-width: 860px) {
  .mobile-topbar { display: flex; }
  body { display: block; }
  aside { position: fixed; right: 0; top: 0; height: 100vh; transform: translateX(100%); z-index: 70; overflow-y: auto; }
  aside.open { transform: translateX(0); }
  #mainSidebar .brand { display: none; }
  #mainSidebar { padding-top: 14px; }
  main { padding: 20px 14px; padding-top: calc(var(--topbar-h) + 14px); }
  .grid-container { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; gap: 10px; }
  /* جرس الإشعارات داخل السايد بار لا يعمل على الموبايل (الباندل يخرج خارج الشاشة بسبب transform الدرج) —
     الجرس الموجود في الـ topbar هو المعتمد على الموبايل */
  .notif-wrap-inline { display: none !important; }

  /* شاشة الصفقة: الشات يأخذ مساحة أوسع */
  .deal-modal-cols { display: block !important; }
  #dealModalBody .grid-3-cols { grid-template-columns: 1fr 1fr !important; }
}

@media (max-width: 520px) {
  #dealModalBody .grid-3-cols { grid-template-columns: 1fr !important; }
  #dealModalBody .modal-actions { flex-direction: column !important; }
  #dealModalBody .modal-actions .btn-buy,
  #dealModalBody .modal-actions .btn-details { width: 100% !important; }
}

@media (max-width: 600px) {
  aside { width: min(280px, 88vw); }
  main { padding: 12px 10px; padding-top: calc(var(--topbar-h) + 10px); }
  .grid-container { grid-template-columns: 1fr; gap: 12px; }

  /* Landing Hero Responsive Fix */
  .landing-hero-actions {
    flex-direction: column !important;
    width: 100% !important;
    gap: 10px !important;
  }
  .landing-hero-actions a, .landing-hero-actions button {
    width: 100% !important;
    text-align: center !important;
    justify-content: center !important;
  }

  .btn-buy, .btn-details, .btn-primary, .btn-secondary {
    font-size: 0.8rem;
    padding: 8px 12px;
  }

  /* ===== تحسينات استجابة لوحة التحكم Admin على الموبايل ===== */
  .page-header {
    flex-direction: column;
    align-items: stretch !important;
    gap: 10px !important;
  }
  .page-header > div:last-child {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 8px !important;
    width: 100%;
  }
  .page-header > div:last-child button {
    width: 100%;
    justify-content: center;
    padding: 8px 6px;
    font-size: 0.78rem;
  }

  .admin-header-nav {
    gap: 6px;
    padding-bottom: 8px;
    margin-bottom: 14px;
  }
  .admin-nav-item {
    padding: 8px 11px;
    font-size: 0.76rem;
    border-radius: 10px;
  }

  #adminStatsGrid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
  }
  #adminStatsGrid .card {
    padding: 12px !important;
    border-radius: 12px !important;
  }
  #adminStatsGrid .card div:first-child {
    font-size: 0.72rem !important;
  }
  #adminStatsGrid .card div:last-child {
    font-size: 1.25rem !important;
  }

  .admin-sec-head {
    flex-direction: column;
    align-items: stretch !important;
    gap: 8px;
  }
  .admin-sec-head h3 {
    font-size: 0.95rem;
  }
  .admin-sec-head > button, .admin-sec-head > a {
    width: 100%;
    justify-content: center;
  }

  .table-wrap {
    border-radius: 10px;
    border: 1px solid var(--border);
    margin-bottom: 14px;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }
  .table-wrap table {
    font-size: 0.78rem;
  }
  .table-wrap th, .table-wrap td {
    padding: 8px 10px;
  }
  .table-wrap td button, .table-wrap td .btn, .table-wrap td a {
    padding: 5px 9px !important;
    font-size: 0.74rem !important;
  }

  /* نوافذ الأمان على الموبايل: لا تتجاوز الشاشة ولا تعمل Layout Shift */
  .dm-dialog-overlay { padding: 10px; }
  .dm-dialog { max-height: calc(100vh - 20px); padding: 20px 16px 16px; }
  .dm-sec-method-card { padding: 10px; }

  /* حقول PIN على الموبايل: تبقى صف واحد لا يلتف — الأرقام تنكمش بنسبة مناسبة */
  .binance-pin-group { max-width: 100%; gap: 6px; }
  .binance-pin-box { height: 46px; font-size: 1.2rem; }

  /* Deal Modal Mobile Fixes */
  #dealModalBody {
    /* lay out المحتوى عمودياً داخل الـ flex modal */
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
    overflow-y: auto !important;
    padding: 12px 10px 14px !important;
    /* لا يُحتاج padding إضافي للـ topbar لأن المودال fullscreen يغطي الشاشة */
  }
  #dealModalBody > div:first-child {
    /* القسم الأول (معلومات الصفقة + صور) لا يزداد ارتفاعاً */
    flex-shrink: 0;
  }
  #dealModalBody .chat-scroll {
    /* الشات يأخذ المساحة المتبقية */
    flex: 1 1 auto !important;
    min-height: 0 !important; /* مهم للسماح بالـ shrink في flex column */
    max-height: calc(100dvh - 220px) !important;
  }
  #dealModalBody .chat-scroll::-webkit-scrollbar { width: 4px; }
  #dealModalBody .chat-scroll::-webkit-scrollbar-thumb { background: var(--red); border-radius: 2px; }

  /* زر الإغلاق على الموبايل: موضعه فوق الكائن الثابت */
  .fullscreen-close { top: 8px !important; left: 8px !important; width: 36px; height: 36px; font-size: 1.2rem; }

  /* أزرار الإجراءات في شريط إجراءات الصفقة: صفة مرنة على الموبايل */
  #dealActionBar {
    padding: 10px 12px !important;
    margin-bottom: 10px !important;
    gap: 8px !important;
  }
  #dealActionBar > div:first-child {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 6px !important;
    width: 100% !important;
  }
  #dealActionBar .btn-buy,
  #dealActionBar .btn-details {
    flex: 1 1 calc(50% - 4px) !important;
    min-width: 120px !important;
    height: 42px !important;
    font-size: 0.8rem !important;
    padding: 6px 8px !important;
    text-align: center !important;
  }

  /* حاوية المحادثة المباشرة على الموبايل */
  .deal-chat-box {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 1 auto !important;
    min-height: 280px !important;
    max-height: calc(100dvh - 200px) !important;
    border-radius: 12px !important;
    overflow: hidden !important;
  }

  /* رسائل الشات: max-width 100% على الموبايل */
  .chat-msg { max-width: 95% !important; font-size: 0.82rem !important; padding: 8px 10px !important; }
  .chat-msg div { font-size: 0.58rem !important; }

  /* زر المرفق والإرسال في صف واحد */
  #dealModalBody input#chatInput { font-size: 0.95rem !important; padding: 10px 14px !important; }
  #dealModalBody button[onclick*="sendMsg"] { min-width: 48px !important; font-size: 0.85rem !important; }

  /* حاوية إدخال الشات على الموبايل: تكبير حقل الكتابة والأزرار بالكامل */
  .deal-chat-input-bar {
    position: sticky !important;
    bottom: 0 !important;
    z-index: 25 !important;
    background: #14121d !important;
    gap: 8px !important;
    padding: 10px 8px calc(10px + env(safe-area-inset-bottom, 0px)) !important;
    align-items: center !important;
    border-top: 1px solid rgba(220, 38, 38, 0.35) !important;
    box-shadow: 0 -6px 16px rgba(0, 0, 0, 0.6) !important;
  }
  .deal-chat-input-bar #chatInput {
    flex: 1 1 auto !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    min-height: 44px !important;
    font-size: 0.95rem !important;
    padding: 10px 14px !important;
    background: #1c1930 !important;
    border: 1px solid #3f3b54 !important;
    border-radius: 12px !important;
    color: #ffffff !important;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2) !important;
  }
  .deal-chat-input-bar #chatInput:focus {
    border-color: var(--red) !important;
    outline: none !important;
    box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.25) !important;
  }
  .deal-chat-input-bar .chat-attach-btn {
    flex: 0 0 auto !important;
    min-width: 44px !important;
    width: 44px !important;
    max-width: 44px !important;
    height: 44px !important;
    padding: 0 !important;
    border-radius: 12px !important;
    font-size: 1.1rem !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }
  #dealModalBody .deal-chat-input-bar .chat-send-btn {
    flex: 0 0 auto !important;
    min-width: 48px !important;
    width: 48px !important;
    max-width: 48px !important;
    height: 44px !important;
    padding: 0 !important;
    border-radius: 12px !important;
    font-size: 1.1rem !important;
    justify-content: center !important;
    display: flex !important;
    align-items: center !important;
  }
  #dealModalBody .deal-chat-input-bar .chat-send-btn span {
    display: none !important;
  }
}

/* ═══════════════════════════════════════════════════════════════
   NOTIFICATION BELL & PANEL (Wishlist/Header)
════════════════════════════════════════════════════════════════ */
.notif-wrap { position: relative; display: inline-flex; }
.notif-wrap .icon-btn {
  background: transparent; border: none; cursor: pointer;
  font-size: 1.5rem; color: #d4d4d8; position: relative;
  padding: 8px 10px; border-radius: 8px; transition: background 0.2s;
}
.notif-wrap .icon-btn:hover { background: #181524; }
.notif-wrap .count-pill {
  position: absolute; top: -2px; right: -6px; background: var(--red);
  color: #fff; font-size: 0.62rem; font-weight: 800; min-width: 17px;
  height: 17px; border-radius: 999px; display: flex; align-items: center;
  justify-content: center; padding: 0 4px;
}
.notif-panel {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 120;
  width: 320px; max-width: 86vw; background: #12101b;
  border: 1px solid var(--border-h); border-radius: 12px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.65);
  overflow: hidden; display: none;
}
.notif-wrap.open .notif-panel { display: block; }

/* زرار الإشعارات داخل الـ sidebar (الصفحات الأساسية) — الـ panel يظهر وسط الشاشة من الأعلى */
.notif-wrap-inline { display: flex; justify-content: center; width: 100%; margin: 12px 0 6px; }
.notif-wrap-inline .icon-btn { width: auto; }
.notif-wrap-inline .notif-panel {
  position: fixed; top: 14px; left: 50%; transform: translateX(-50%);
  width: min(360px, 94vw);
}
.notif-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  background: #181524;
}
.notif-head strong { color: #fff; font-size: 0.88rem; }
.notif-list { max-height: 340px; overflow-y: auto; }
.notif-item {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 14px; border-bottom: 1px solid #14121d;
  cursor: default; transition: background 0.15s;
}
.notif-item:hover { background: #181524; }
.notif-item.read { opacity: 0.65; }
.notif-item .ni-ico { font-size: 1rem; margin-top: 2px; flex-shrink: 0; display: flex; align-items: center; }
.notif-item .ni-body strong { color: #fff; font-size: 0.82rem; display: block; }
.notif-item .ni-body span { color: #a1a1aa; font-size: 0.75rem; line-height: 1.5; display: block; }
.notif-item .ni-time { color: #52525b; font-size: 0.68rem; margin-top: 4px; }
.notif-item .ni-action {
  background: transparent; border: 1px solid var(--border-h); color: #a1a1aa;
  width: 28px; height: 28px; border-radius: 8px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all 0.15s; flex-shrink: 0;
}
.notif-item .ni-action i { font-size: 0.82rem; }
.notif-item .ni-action:hover { color: #fff; border-color: var(--accent, #6d5bd0); }
.notif-item .ni-action:hover[title="حذف"] { color: #ef4444; border-color: rgba(239,68,68,0.5); }
.notif-empty { color: #71717a; font-size: 0.8rem; text-align: center; padding: 24px; }

/* ═══════════════════════════════════════════════════════════════
   PROFESSIONAL IMAGE UPLOAD (Dropzone)
════════════════════════════════════════════════════════════════ */
.dm-dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 150px;
  border: 2px dashed var(--border-h);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255,255,255,.02), rgba(255,255,255,0));
  cursor: pointer;
  padding: 18px;
  text-align: center;
  transition: border-color .2s, background .2s, transform .15s;
  overflow: hidden;
}
.dm-dropzone:hover { border-color: var(--accent, #6d5bd0); background: rgba(109, 91, 208, .05); }
.dm-dropzone.drag-over { border-color: var(--green, #22c55e); background: rgba(34, 197, 94, .07); transform: scale(1.01); }
.dm-dropzone.has-file { border-style: solid; border-color: var(--green, #22c55e); background: rgba(34, 197, 94, .04); }

.dm-dropzone .dz-icon {
  width: 56px; height: 56px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(109, 91, 208, .18), rgba(109, 91, 208, .06));
  border: 1px solid rgba(109, 91, 208, .25);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  color: var(--accent, #8b7cf6);
  transition: transform .2s;
}
.dm-dropzone:hover .dz-icon { transform: translateY(-3px); }
.dm-dropzone .dz-title {
  color: #fff; font-size: .92rem; font-weight: 700;
}
.dm-dropzone .dz-hint { color: var(--muted, #808090); font-size: .75rem; line-height: 1.6; }
.dm-dropzone .dz-file-name {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(34, 197, 94, .12);
  border: 1px solid rgba(34, 197, 94, .35);
  color: var(--green, #22c55e);
  font-size: .78rem; font-weight: 700;
  padding: 4px 12px; border-radius: 999px;
}
.dm-dropzone .dz-preview {
  width: 74px; height: 74px;
  border-radius: 12px;
  object-fit: cover;
  border: 2px solid rgba(255,255,255,.14);
  box-shadow: 0 8px 22px rgba(0,0,0,.35);
}
.dm-dropzone input[type="file"] {
  position: absolute; inset: 0;
  opacity: 0; cursor: pointer;
  width: 100%; height: 100%;
}
.dm-dropzone .dz-remove {
  position: absolute; top: 8px; left: 8px;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: rgba(220, 38, 38, .85);
  border: none; color: #fff;
  font-size: .8rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 10px rgba(0,0,0,.4);
  transition: transform .15s;
  z-index: 2;
}
.dm-dropzone .dz-remove:hover { transform: scale(1.12); }
.dm-dropzone .dz-remove-txt {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--accent, #8b7cf6); font-size: .78rem; font-weight: 700;
  background: rgba(109, 91, 208, .1);
  border: 1px dashed rgba(109, 91, 208, .35);
  padding: 6px 14px; border-radius: 999px;
  cursor: pointer; transition: all .15s;
}
.dm-dropzone .dz-remove-txt:hover { background: rgba(109, 91, 208, .2); }

/* ═══════════════════════════════════════════════════════════════
   LEGACY UTILITIES (upload / wishlist / arbitration pages)
════════════════════════════════════════════════════════════════ */
.card-pad { padding: 24px; }
.section { margin-bottom: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.flex { display: flex; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 12px; }
.hr { height: 1px; background: var(--border, #1a1825); border: none; margin: 16px 0; }
.text-muted { color: var(--muted, #808090); }
.text-small { font-size: 0.8rem; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.btn-label { display: inline-flex; align-items: center; gap: 8px; }
.btn-lg { padding: 12px 22px; font-size: 0.95rem; }
.btn-block { width: 100%; justify-content: center; display: inline-flex; }

.alert { padding: 12px 14px; border-radius: 10px; font-size: 0.85rem; margin-bottom: 14px; display: none; }
.alert.show { display: block; }
.alert-error { background: rgba(220,38,38,0.12); border: 1px solid rgba(220,38,38,0.3); color: #f87171; }
.alert-success { background: rgba(34,197,94,0.12); border: 1px solid rgba(34,197,94,0.3); color: #4ade80; }

.kicker { font-size: 0.78rem; font-weight: 800; color: var(--accent, #8b7cf6); letter-spacing: 0.5px; text-transform: uppercase; }

.list { display: flex; flex-direction: column; gap: 8px; }
.list-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--panel-bg, #12101b); border: 1px solid var(--border, #1a1825);
  border-radius: 10px; padding: 12px 14px; flex-wrap: wrap;
}
.row-main { flex: 1; min-width: 180px; }
.row-title { color: #fff; font-weight: 700; font-size: 0.92rem; }
.row-sub { color: var(--muted, #808090); font-size: 0.78rem; margin-top: 2px; }
.row-amt { color: var(--green, #22c55e); font-weight: 800; font-size: 0.9rem; direction: ltr; white-space: nowrap; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.info-grid { display: grid; gap: 12px; }
.info-item label { display: block; font-size: 0.75rem; color: var(--muted, #808090); margin-bottom: 3px; font-weight: 600; }
.info-item .iv { color: #fff; font-size: 0.92rem; font-weight: 600; word-break: break-word; }
.info-item .iv.money { color: var(--green, #22c55e); direction: ltr; }

.empty { text-align: center; padding: 48px 20px; color: var(--muted, #808090); }
.empty .e-ico { font-size: 2.6rem; display: block; margin-bottom: 12px; }
.empty h3 { color: #fff; font-size: 1.15rem; margin-bottom: 6px; }

.modal-ico { display: block; font-size: 2.2rem; text-align: center; margin-bottom: 10px; }
.ob-step { padding: 8px 0; }
.form-row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

.tag {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.75rem; font-weight: 700; padding: 4px 10px; border-radius: 999px;
  background: rgba(255,255,255,0.05); border: 1px solid var(--border-h, #2e2a42); color: var(--muted, #808090);
}
.tag-green { background: rgba(34,197,94,0.12); border-color: rgba(34,197,94,0.3); color: #4ade80; }

.spinner {
  display: inline-block; width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.25); border-top-color: currentColor;
  border-radius: 50%; animation: spin 0.7s linear infinite;
  vertical-align: middle;
  flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* الأزرار: الـ spinner مخفي افتراضياً، وبيظهر بس لما الزر فعلاً في حالة .loading */
.btn .spinner, .btn-buy .spinner, .btn-primary .spinner, .btn-details .spinner,
.btn-secondary .spinner, .btn-brand .spinner, .btn-ghost .spinner, .btn-danger .spinner,
.btn-signin .spinner, .btn-icon .spinner, .btn-sm .spinner, .btn-lg .spinner {
  display: none;
}
.btn.loading .spinner, .btn-buy.loading .spinner, .btn-primary.loading .spinner,
.btn-details.loading .spinner, .btn-secondary.loading .spinner, .btn-brand.loading .spinner,
.btn-ghost.loading .spinner, .btn-danger.loading .spinner, .btn-signin.loading .spinner,
.btn-icon.loading .spinner, .btn-sm.loading .spinner, .btn-lg.loading .spinner {
  display: inline-block;
}

/* مظهر الزر أثناء الشغل: يخفي النص ويبحث عليه + يمنع الضغط المتكرر */
.btn.loading, .btn-buy.loading, .btn-primary.loading, .btn-details.loading,
.btn-secondary.loading, .btn-brand.loading, .btn-ghost.loading, .btn-danger.loading,
.btn-signin.loading, .btn-icon.loading {
  pointer-events: none;
  cursor: wait;
  opacity: 0.8;
  filter: saturate(0.85);
}
.btn.loading .btn-label, .btn-buy.loading .btn-label, .btn-primary.loading .btn-label,
.btn-details.loading .btn-label, .btn-secondary.loading .btn-label, .btn-brand.loading .btn-label,
.btn-ghost.loading .btn-label, .btn-danger.loading .btn-label, .btn-signin.loading .btn-label {
  visibility: hidden;
}
.btn.loading .btn-label i, .btn.loading .btn-label .fa-solid,
.btn.loading .btn-label .fa, .btn.loading > .fa-solid, .btn.loading > .fa,
.btn.loading > .fab { visibility: hidden; }

/* Sensitive-action dialog extra spacing */
.dm-sec-actions .btn { width: 100%; }
.dm-sec-method-card { background: rgba(255,255,255,.03); }
.dm-sec-method-card:hover { background: rgba(255,255,255,.05); }
.dm-sec-method-card .dm-sec-extra { margin-top: 2px; }

/* Security checkbox styling — matches dark luxury theme */
.dm-sec-check {
  width: 16px;
  height: 16px;
  accent-color: var(--accent, #8b7cf6);
  flex: none;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.dm-sec-check:hover {
  transform: scale(1.08);
}
.dm-sec-check:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(139, 124, 246, 0.4);
  border-radius: 3px;
}
.dm-sec-check:checked {
  animation: dm-sec-check-pop 0.2s ease;
}
@keyframes dm-sec-check-pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

/* Card selected state — border highlights on check */
.dm-sec-method-card.has-selection {
  border-color: var(--accent, #8b7cf6) !important;
  background: rgba(139, 124, 246, 0.06);
}

/* General form checkboxes — consistent with theme */
input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent, #8b7cf6);
  cursor: pointer;
  flex: none;
  transition: transform 0.15s ease;
}
input[type="checkbox"]:hover {
  transform: scale(1.08);
}
input[type="checkbox"]:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(139, 124, 246, 0.4);
  border-radius: 3px;
}
input[type="checkbox"]:checked {
  animation: dm-sec-check-pop 0.2s ease;
}

/* ── Inline validation states for .field inputs ── */
.field.invalid {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
  background: #1a1216;
}
.field.invalid:focus {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.25);
}
.field.valid {
  border-color: rgba(34, 197, 94, 0.55);
}
.field.valid:focus {
  border-color: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18);
}
.field-hint {
  font-size: 0.75rem;
  margin-top: 4px;
  display: none;
}
.field-hint.show {
  display: block;
}
.field-hint.ok { color: #22c55e; }
.field-hint.err { color: #f87171; }