/* ============================================================
   ForexBro Mobile Fixes — addresses clickability + overflow
   Loaded AFTER all other CSS so rules win.
   ============================================================ */

/* Prevent any horizontal overflow on small screens */
html, body { max-width: 100%; overflow-x: hidden; }

/* ============================================================
   SIDEBAR CLOSE (X) + BACKDROP — mobile only
   ============================================================ */
.sidebar-close {
  display: none;
  position: absolute;
  top: 14px;
  inset-inline-end: 14px;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  color: #fff;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  padding: 0;
  z-index: 5;
  transition: background 0.18s ease;
}
.sidebar-close:hover { background: rgba(255,255,255,0.12); }
.sidebar-close svg { width: 20px; height: 20px; display: block; }

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(2px);
  z-index: 199;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.sidebar-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

/* Lock body scroll while sidebar is open on mobile */
body.sidebar-locked { overflow: hidden; }

/* ============================================================
   SIDEBAR USER ID — clickable copy under the name
   ============================================================ */
.sidebar-user-id {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: 'JetBrains Mono', 'SF Mono', monospace;
  font-size: 10px;
  color: var(--text-muted);
  cursor: pointer;
  margin: 4px 0 4px;
  padding: 2px 0;
  user-select: all;
  transition: color 0.18s ease;
}
.sidebar-user-id .lbl {
  font-family: inherit;
  opacity: 0.55;
  letter-spacing: 0.3px;
}
.sidebar-user-id code {
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 8px;
  border-radius: 5px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.3px;
  color: var(--text-secondary);
  border: 1px solid rgba(255, 255, 255, 0.06);
  transition: all 0.18s ease;
}
.sidebar-user-id:hover code {
  color: var(--accent-gold);
  border-color: rgba(255, 184, 0, 0.25);
  background: rgba(255, 184, 0, 0.08);
}
.sidebar-user-id.copied code {
  color: var(--accent-green, #00FF87);
  background: rgba(0, 255, 135, 0.1);
  border-color: rgba(0, 255, 135, 0.25);
}

@media (max-width: 768px) {
  .sidebar-close { display: inline-flex; }
  /* Add room for the close button next to the logo on mobile */
  .sidebar-header { padding-inline-end: 56px !important; }
}
@media (min-width: 769px) {
  .sidebar-backdrop { display: none !important; }
}

@media (max-width: 768px) {
  /* ====== HOME PAGE (index.html) ====== */
  .nav-inner { padding: 0 12px; gap: 6px; flex-wrap: nowrap; min-width: 0; }
  .nav-links { display: none; }   /* Hide desktop nav on mobile (mobile menu handles it) */
  .nav-right { gap: 6px; flex-shrink: 1; min-width: 0; }
  .nav-right .btn-ghost,
  .nav-right .btn-primary {
    padding: 8px 11px !important;
    font-size: 12px !important;
    white-space: nowrap;
    min-height: 40px;
    /* Important: do NOT force display here — auth-logic.js needs to be the
       single source of truth for which nav buttons are visible (login+start
       when logged out, dashboard when logged in). Earlier we forced
       inline-flex which un-hid login even when JS hid it; AND we hard-hid
       data-nav-start which made signup invisible on mobile. Both gone now. */
    align-items: center;
    justify-content: center;
  }
  .lang-toggle, .lang-switch { padding: 3px; flex-shrink: 0; }
  .lang-toggle span, .lang-switch span { padding: 5px 9px; font-size: 10px; }
  /* Allow logo to shrink so buttons fit, but keep the "ForexBro" wordmark visible.
     The compact navbar rules in styles.css already shrink the lang pill + CTAs
     so the brand text always fits. (Old rule that hid the wordmark on mobile
     was removed on 2026-05-24 at owner request.) */
  .nav-inner .logo { flex-shrink: 1; min-width: 0; }
  .nav-inner .logo .logo-text { display: inline !important; }
  /* 2026-06-01: تكبير متناسق لعناصر هيدر الرئيسية مع الهيدر (84px).
     النص يطابق اللوقو (نسبة ~٥٢٪) ومسافات أوسع للتنفّس. */
  .nav-inner .logo-mark { width: 42px !important; height: 42px !important; }
  .nav-inner .logo { gap: 9px !important; }
  .nav-inner .logo .logo-text { font-size: 20px !important; }
  .nav-right .lang-toggle span { padding: 6px 10px !important; font-size: 11px !important; }
  .mobile-menu-btn { padding: 6px !important; }
  .mobile-menu-btn svg { width: 26px !important; height: 26px !important; }

  /* 2026-06-01: سجل عمولات المسوّقين على الجوال — تحويل الجدول لبطاقات
     مقروءة بتسميات بدل الصفوف المكدّسة يميناً (كانت بدائية وغير واضحة). */
  .aff-comm-table thead { display: none; }
  .aff-comm-table, .aff-comm-table tbody { display: block; width: 100%; }
  .aff-comm-table tr {
    display: block;
    background: var(--bg-tertiary, #151A2E);
    border: 1px solid var(--border-subtle, rgba(255,255,255,0.07));
    border-radius: 14px;
    padding: 4px 15px;
    margin-bottom: 12px;
  }
  .aff-comm-table td[data-label] {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 11px 0 !important;
    border: none !important;
    text-align: end !important;
    font-size: 14px;
  }
  .aff-comm-table td[data-label]:not(:last-child) {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
  }
  .aff-comm-table td[data-label]::before {
    content: attr(data-label);
    color: var(--text-muted, #9ca3af);
    font-size: 12px;
    font-weight: 600;
    text-align: start;
    white-space: nowrap;
    flex-shrink: 0;
  }

  .hero { padding: 112px 0 40px; }   /* nav is position:fixed → keep the badge clear of it (was 80px, looked glued to the header) */
  .hero-grid {
    display: flex !important;
    flex-direction: column !important;
    gap: 28px;
  }
  /* Make hero-content's children direct children of the flex parent so
     `order` can interleave the signal card between subtitle/buttons
     and the stats row on mobile. */
  .hero .hero-content {
    display: contents !important;
  }
  .hero .hero-badge   { order: 1; }
  .hero h1            { order: 2; }
  .hero .hero-content > p { order: 3; }
  .hero .hero-actions { order: 4; }
  .hero .hero-visual  { order: 5; margin: 8px 0; }
  .hero .hero-stats   { order: 6; }

  .hero h1 { font-size: 46px !important; line-height: 1.05; letter-spacing: -1.5px; font-weight: 800 !important; }
  .hero-actions { flex-wrap: wrap; gap: 10px; }
  .hero-actions .btn { flex: 1 1 100%; justify-content: center; }
  /* Stats: 3 cards in a single row on mobile (matches desktop layout). */
  .hero-stats {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 8px !important;
    width: 100% !important;
    padding-top: 24px !important;
  }
  .hero-stat {
    padding: 12px 8px !important;
    align-items: center !important;
    text-align: center;
    min-width: 0 !important;
    gap: 4px !important;
  }
  .hero-stat-icon {
    width: 30px !important;
    height: 30px !important;
    border-radius: 8px !important;
  }
  .hero-stat-icon svg { width: 16px !important; height: 16px !important; }
  .hero-stat-num { font-size: 19px !important; letter-spacing: -0.5px !important; }
  .hero-stat-label { font-size: 9.5px !important; line-height: 1.25 !important; }
  /* Signal card: full-width on mobile so it doesn't look squished. */
  .hero-visual {
    display: flex !important;
    justify-content: center;
    margin-top: 8px;
    width: 100%;
  }
  .hero-visual .signal-card {
    max-width: 100%;
    width: 100%;
    padding: 20px;
    box-shadow: 0 16px 50px -12px rgba(0,0,0,0.7), 0 0 0 1px rgba(255,184,0,0.1);
  }

  .section-title { font-size: 26px !important; }
  .features-grid,
  .perf-stats,
  .pricing-grid,
  .tools-grid { grid-template-columns: 1fr !important; gap: 14px; }

  .pricing-toggle-wrap { padding: 0 12px; margin-top: 0; margin-bottom: 28px; }
  .pricing-toggle {
    width: auto;
    max-width: 100%;
    /* Give the toggle enough headroom for the floating "Save 25%" badge so the
       Yearly tab doesn't get visually clipped. */
    margin-top: 18px;
  }
  .pricing-toggle span {
    padding: 9px 16px;
    font-size: 13px;
    white-space: nowrap;
  }
  .pricing-toggle span > span[data-i18n="pricing_yearly"],
  .pricing-toggle span[data-period="yearly"] > span:not(.save-badge) {
    display: inline-block;
  }
  /* Push the badge above the pill, not overlapping the Yearly text. */
  .pricing-toggle .save-badge {
    top: -16px;
    right: 50%;
    transform: translateX(50%);
    font-size: 9px;
    padding: 2px 7px;
    white-space: nowrap;
  }
  [dir="rtl"] .pricing-toggle .save-badge { right: 50%; left: auto; }

  .perf-stats { grid-template-columns: repeat(2, 1fr) !important; }
  .perf-stat { padding: 14px !important; }
  .perf-stat-num { font-size: 22px !important; }

  /* ── FOOTER ── */
  .footer-grid {
    grid-template-columns: 1fr !important;
    gap: 28px !important;
    text-align: center !important;
    margin-bottom: 28px !important;
  }
  .footer-grid > div {
    display: flex;
    flex-direction: column;
    align-items: center;
  }
  .footer-grid .footer-about {
    max-width: 320px;
    margin: 0 auto;
    line-height: 1.6;
  }
  .footer-grid h4 {
    margin-bottom: 12px;
    letter-spacing: 1px;
  }
  .footer-grid ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
  }
  .footer-grid ul li a { font-size: 14px; }
  .footer-brand .logo { justify-content: center; }

  /* ── Trust block ── */
  .footer-trust { padding: 18px 12px !important; margin: 8px 0 20px !important; }
  .footer-trust-title { font-size: 11px !important; margin-bottom: 14px !important; }
  .footer-trust-row { gap: 6px !important; }
  .footer-trust-certs { margin-bottom: 12px !important; }
  .footer-trust-cert {
    padding: 6px 9px !important;
    font-size: 10.5px !important;
    gap: 6px !important;
  }
  .footer-trust-cert svg { width: 14px !important; height: 14px !important; }

  /* Payment badges row */
  .footer-trust-pay {
    padding-top: 12px !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 8px !important;
  }
  .footer-trust-pay-label {
    width: 100% !important;
    text-align: center !important;
    margin-bottom: 4px !important;
  }
  .footer-pay-badge {
    height: 26px !important;
    padding: 0 10px !important;
    font-size: 10.5px !important;
  }
  /* Wrap payment badges into rows of 3 on phones */
  .footer-trust-pay {
    flex-wrap: wrap !important;
    flex-direction: row !important;
    justify-content: center !important;
  }

  .footer-disclaimer { font-size: 11.5px !important; line-height: 1.7 !important; }
  .footer-bottom { font-size: 12px !important; }

  .ticker { display: none; }   /* Hide ticker on mobile to save space */

  /* Demo signal card on hero — full width, no narrow cap */
  .signal-card { width: 100% !important; max-width: 100% !important; margin: 0 auto; }

  /* ====== DASHBOARD ====== */
  .app { display: block !important; }
  .sidebar {
    position: fixed;
    inset-inline-start: 0;
    top: 0;
    bottom: 0;
    width: 280px;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 200;
    overflow-y: auto;
    /* لا يُرسم رأس القائمة + زر الإغلاق تحت شريط النظام في وضع PWA */
    padding-top: env(safe-area-inset-top, 0px);
  }
  [dir="rtl"] .sidebar { transform: translateX(100%); }
  .sidebar.open { transform: translateX(0) !important; }

  /* المنطقة الآمنة (notch/Dynamic Island): في وضع PWA المثبّت كان الشريط العلوي
     يُرسم تحت ساعة/بطارية الجوال فيتعذّر ضغط الهامبرجر. نُنزّل محتوى الشريط أسفل
     شريط النظام بإضافة env(safe-area-inset-top). على الأجهزة بلا حافّة = 0 (بلا تغيير)
     — وهذا يفسّر تضارب الشكوى بين العملاء. */
  .topbar {
    padding: 12px 16px !important;
    padding-top: calc(12px + env(safe-area-inset-top, 0px)) !important;
    padding-inline-start: max(16px, env(safe-area-inset-left, 0px)) !important;
    padding-inline-end: max(16px, env(safe-area-inset-right, 0px)) !important;
  }
  .topbar-title { font-size: 16px !important; }
  .topbar-search { display: none !important; }
  .topbar-right { gap: 8px; }
  .topbar-btn { width: 32px; height: 32px; }

  /* Sidebar toggle button (hamburger) on mobile */
  .sidebar-toggle, .mobile-menu-btn { display: inline-flex !important; }

  .content { padding: 16px !important; }
  .content > .stats-grid,
  .content .stats-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 10px; }
  .stat-card { padding: 14px !important; }
  .stat-card-value { font-size: 22px !important; }
  .card { padding: 16px !important; }
  .card-head { padding: 14px 0 !important; flex-wrap: wrap; gap: 8px; }
  .card-title { font-size: 14px !important; }

  /* Hero on dashboard */
  .fb-hero { padding: 18px 16px !important; }
  .fb-hero-name { font-size: 22px !important; }
  .fb-hero-row { flex-direction: column !important; }
  .fb-hero-row > div { min-width: 100% !important; text-align: start !important; }

  /* Tables — handled by the card-conversion block lower in this file
     (search "MOBILE TABLE → CARDS"). DO NOT add min-width here; it
     forces the row to overflow even after the card transform. */

  /* Buttons need larger tap targets */
  .btn { min-height: 38px; padding: 8px 14px; font-size: 13px; }
  .btn-lg { min-height: 46px; padding: 12px 20px; font-size: 14px; }

  /* Modals fit screen */
  .fb-modal, .modal-card { max-width: calc(100vw - 24px) !important; max-height: calc(100vh - 24px); overflow-y: auto; }
  .fb-overlay { padding: 12px !important; align-items: center !important; }

  /* Support wizard (new-ticket popup) — fit screen, no overflow.
     Use 100dvh so the iOS Safari URL bar doesn't push the foot below
     the visible viewport. Reserve space for the footer with safe-area. */
  .sup-wizard-overlay {
    padding: 8px !important;
    align-items: flex-start !important;
    padding-top: 16px !important;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px)) !important;
  }
  .sup-wizard {
    width: 100% !important;
    max-width: 100% !important;
    max-height: calc(100dvh - 32px - env(safe-area-inset-bottom, 0px)) !important;
    border-radius: 14px !important;
    display: flex !important;
    flex-direction: column !important;
  }
  .sup-wizard-head { padding: 14px 16px !important; flex-shrink: 0; }
  .sup-wizard-title { font-size: 15px !important; }
  .sup-wizard-steps { padding: 10px 16px !important; flex-shrink: 0; }
  .sup-wizard-body {
    padding: 14px 16px !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
  }
  .sup-wizard-foot {
    padding: 12px 14px !important;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)) !important;
    flex-wrap: wrap;
    gap: 8px !important;
    flex-shrink: 0 !important;
    position: sticky;
    bottom: 0;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-subtle);
  }
  .sup-wizard-foot > * { flex: 1 1 auto; min-width: 0; }
  .sup-cat-grid { grid-template-columns: 1fr !important; gap: 8px !important; }
  .sup-cat-card { padding: 12px !important; }
  .sup-field { margin-bottom: 12px !important; }
  .sup-field-textarea { min-height: 96px !important; }
  /* Char counter on mobile — clearly under the field, never overlaps */
  .sup-char-counter {
    display: block !important;
    float: none !important;
    text-align: end;
    font-size: 10.5px !important;
    margin-top: 4px !important;
    padding: 0 2px;
    line-height: 1.3;
    color: var(--text-muted);
  }
  .sup-uploader { padding: 14px !important; }

  /* Support chat — fit viewport, scroll body, sticky composer.
     Use 100dvh + safe-area-inset-bottom so the send button isn't
     pushed off-screen behind the iOS Safari URL bar / home indicator. */
  .sup-chat {
    height: calc(100dvh - 96px - env(safe-area-inset-bottom, 0px)) !important;
    min-height: 0 !important;
    max-height: calc(100dvh - 96px - env(safe-area-inset-bottom, 0px)) !important;
    border-radius: 12px !important;
  }
  .sup-chat-head { padding: 10px 12px !important; gap: 8px !important; }
  .sup-chat-subject { font-size: 14px !important; }
  .sup-chat-num { font-size: 10px !important; }
  .sup-chat-meta-line { font-size: 10px !important; }
  .sup-chat-body { padding: 12px !important; gap: 8px !important; }
  .sup-msg { max-width: 90% !important; gap: 6px !important; }
  .sup-bubble { padding: 9px 12px !important; font-size: 13px !important; }
  .sup-compose {
    padding: 10px 12px !important;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)) !important;
  }
  .sup-compose-row { gap: 6px !important; }
  .sup-compose-input {
    font-size: 14px !important;
    min-height: 40px !important;
    max-height: 100px !important;
    padding: 9px 12px !important;
  }
  .sup-compose-btn { width: 40px !important; height: 40px !important; font-size: 16px !important; }
  .sup-compose-attach-row { grid-template-columns: repeat(auto-fill, 64px) !important; }
  .sup-closed-banner {
    padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px)) !important;
  }

  /* Checkout grid — stack */
  .chk-main, .chk-grid { grid-template-columns: 1fr !important; gap: 16px; }

  /* ============================================================
     ADMIN/DASHBOARD PAGE FIXES — overflow + spacing
     ============================================================ */

  /* Topbar — refined for mobile (taller, better separated, breathable) */
  .topbar {
    height: auto !important;
    min-height: 68px !important;
    padding: 12px 14px !important;
    gap: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06) !important;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.02), 0 6px 18px rgba(0, 0, 0, 0.25);
    background: linear-gradient(180deg, rgba(15, 19, 32, 0.92), rgba(10, 14, 26, 0.85)) !important;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
  }
  .topbar-left, .topbar-right { gap: 10px !important; }
  .topbar-title, #pageTitle {
    font-size: 16px !important;
    font-weight: 700 !important;
    max-width: 60vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .topbar-subtitle {
    font-size: 11px !important;
    color: var(--text-muted) !important;
    margin-top: 2px;
    max-width: 60vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .topbar-actions { gap: 8px !important; }
  .topbar-actions .icon-btn { width: 36px !important; height: 36px !important; }
  .topbar-actions .lang-toggle,
  .topbar-actions .lang-switch {
    padding: 2px !important;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
  }
  .topbar-actions .lang-toggle span,
  .topbar-actions .lang-switch span { padding: 5px 10px !important; font-size: 11px !important; border-radius: 999px; }
  .menu-toggle, .mobile-toggle {
    width: 38px;
    height: 38px;
    border-radius: 10px !important;
    background: rgba(255, 255, 255, 0.04) !important;
    border: 1px solid rgba(255, 255, 255, 0.07) !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }
  /* Hide desktop search inside topbar on mobile */
  .search-wrap { display: none !important; }

  /* Real-time / status indicator pill in topbar — tidy */
  #rtIndicator {
    font-size: 11px !important;
    padding: 5px 9px !important;
    border-radius: 999px !important;
    background: rgba(255, 255, 255, 0.04) !important;
    border: 1px solid rgba(255, 255, 255, 0.06) !important;
    white-space: nowrap;
  }

  /* Homepage nav-inner — same separator + padding refinement.
     2026-06-01: هيدر الجوال كان نحيفاً — كُبّر قليلاً (ارتفاع وحشو أعلى). */
  .nav-inner {
    min-height: 74px !important;
    padding: 13px 12px !important;
    gap: 8px !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  }

  /* Page header — stack vertically, full-width buttons */
  .page-header { flex-direction: column; align-items: stretch !important; gap: 12px !important; margin-bottom: 18px !important; }
  .page-header > div { width: 100%; }
  .page-header .flex { flex-wrap: wrap; gap: 8px; }
  .page-header .flex .btn { flex: 1 1 auto; justify-content: center; }
  .page-title { font-size: 20px !important; letter-spacing: -0.3px !important; }
  .page-subtitle { font-size: 13px !important; }

  /* Tables — admin only uses .tbl-wrap; .table-wrap (customer) becomes
     cards via the "MOBILE TABLE → CARDS" block. */
  .tbl-wrap { overflow-x: auto !important; -webkit-overflow-scrolling: touch; max-width: 100%; }
  .tbl-wrap table { min-width: 540px; }

  /* Cards/grids — prevent horizontal overflow inside content */
  .content { overflow-x: hidden !important; }
  .grid-2, .grid-3 { grid-template-columns: 1fr !important; gap: 14px !important; }

  /* Card header (admin uses .card-header, dashboard uses .card-head) */
  .card-header { flex-wrap: wrap; gap: 8px !important; padding: 12px 0 !important; }
  .card-header .tabs { overflow-x: auto; max-width: 100%; }
  .card-title { font-size: 14px !important; }
  .card-desc { font-size: 12px !important; }

  /* Tabs — horizontal scroll instead of wrap (admin partner tabs) */
  .adm-ptabs, .ptabs, .tabs { overflow-x: auto !important; flex-wrap: nowrap !important; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
  .adm-ptabs::-webkit-scrollbar, .tabs::-webkit-scrollbar { height: 0; }

  /* Page-level tabs (top of admin dashboards) */
  [data-adm-tab], [data-page-tab] { white-space: nowrap; }

  /* Stat cards — chart values and deltas */
  .stat-value { font-size: 22px !important; }
  .stat-delta { font-size: 11px !important; }

  /* KPI strip in admin partners */
  .adm-partners-kpi { grid-template-columns: repeat(2, 1fr) !important; gap: 8px !important; }
  .adm-kpi-card { padding: 14px !important; }
  .adm-kpi-num { font-size: 20px !important; }
  .adm-kpi-icon { font-size: 18px !important; margin-bottom: 4px !important; }
  .adm-kpi-lbl { font-size: 11px !important; }

  /* Affiliate detail modal — fit screen */
  .adm-aff-modal, .adm-app-modal, .adm-mc-modal { max-width: calc(100vw - 16px) !important; max-height: calc(100vh - 24px); margin: 12px !important; }
  .adm-aff-detail-stats { grid-template-columns: repeat(2, 1fr) !important; gap: 8px !important; }

  /* Action strip on admin */
  .adm-action-strip { flex-direction: column; gap: 8px !important; padding: 12px !important; }
  .adm-action-strip > * { width: 100%; }

  /* Form rows — stop fixed widths from causing overflow */
  input, textarea, select, .form-input { max-width: 100%; box-sizing: border-box; }

  /* Hero/header rows that use inline flex on desktop — let them stack on mobile */
  .fb-hero-row[style*="flex"] { flex-direction: column !important; align-items: stretch !important; }
  .fb-hero-row[style*="flex"] > div { min-width: 0 !important; width: 100%; }
}

/* Very small phones — avoid 2-col stat grids cramping */
@media (max-width: 420px) {
  .content > .stats-grid,
  .content .stats-grid { grid-template-columns: 1fr !important; }
  .adm-partners-kpi { grid-template-columns: 1fr !important; }
  .page-title { font-size: 18px !important; }
}

/* Larger phones / small tablets */
@media (max-width: 1024px) and (min-width: 769px) {
  .hero-grid { grid-template-columns: 1fr !important; gap: 40px; }
  .features-grid { grid-template-columns: repeat(2, 1fr); }
  .pricing-grid { grid-template-columns: repeat(2, 1fr); }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Force at least 16px font on inputs to prevent iOS zoom */
@media (max-width: 768px) {
  input, textarea, select { font-size: 16px !important; }
}

/* ───────────────────────────────────────────────────────────────
   MOBILE TABLE → CARDS (2026-05-18)
   Phones can't fit 6–7 column tables. Each row becomes a card,
   each cell shows "Label: value" stacked. data-label attribute
   on the <td> is required (set in JS row builders).
   ─────────────────────────────────────────────────────────────── */
@media (max-width: 720px) {
  /* Force the card container itself to respect the viewport. */
  .table-wrap {
    overflow-x: hidden !important;
    border: none !important;
    background: transparent !important;
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 !important;
    box-sizing: border-box !important;
  }
  .table-wrap table.table {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;          /* kill any min-width inherited from desktop rules */
    table-layout: auto !important;
    box-sizing: border-box !important;
  }
  .table-wrap table.table thead {
    display: none !important;
  }
  .table-wrap table.table tbody {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }
  .table-wrap table.table tr {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    background: var(--bg-card, rgba(255,255,255,0.03)) !important;
    border: 1px solid var(--border-subtle, rgba(255,255,255,0.08)) !important;
    border-radius: 12px !important;
    padding: 12px !important;
    margin-bottom: 10px !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.18) !important;
    overflow: hidden !important;
  }
  .table-wrap table.table td {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    gap: 10px !important;
    padding: 7px 0 !important;
    border-bottom: 1px solid rgba(255,255,255,0.05) !important;
    text-align: end !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    word-break: break-word !important;
    overflow-wrap: anywhere !important;
    white-space: normal !important;
    min-height: 30px;
  }
  .table-wrap table.table td:last-child { border-bottom: none !important; }
  .table-wrap table.table td::before {
    content: attr(data-label);
    display: inline-block;
    font-size: 10.5px;
    font-weight: 700;
    color: var(--text-muted, #9ca3af);
    letter-spacing: 0.4px;
    text-transform: uppercase;
    text-align: start;
    flex: 0 0 auto;
    min-width: 72px;
    max-width: 40%;
  }
  /* Right-side value column shrinks to fit and wraps when needed. */
  .table-wrap table.table td > *:not(::before) {
    min-width: 0 !important;
    max-width: 100% !important;
    text-align: end;
    word-break: break-word;
    overflow-wrap: anywhere;
  }
  /* Pair cell: icon + label, cap label width so long names wrap inside */
  .table-wrap table.table td .table-pair {
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px !important;
    justify-content: flex-end !important;
    min-width: 0 !important;
    max-width: 100% !important;
    flex-wrap: wrap !important;
  }
  .table-wrap table.table td .table-pair .table-pair-name {
    min-width: 0 !important;
    max-width: 100% !important;
    white-space: normal !important;
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
    font-size: 12.5px !important;
    line-height: 1.3 !important;
  }
  .table-wrap table.table td .table-pair img,
  .table-wrap table.table td .table-pair svg,
  .table-wrap table.table td .table-pair .pair-icon {
    width: 22px !important;
    height: 22px !important;
    flex: 0 0 auto !important;
  }
  .table-wrap table.table td .badge {
    margin-inline-start: auto;
  }
  /* Numeric cells: smaller monospaced font fits long numbers */
  .table-wrap table.table td.table-num {
    font-size: 13px !important;
  }
  /* Loading / empty single-cell rows: skip card framing */
  .table-wrap table.table tr td[colspan]::before { content: none !important; }
  .table-wrap table.table tr td[colspan] {
    text-align: center !important;
    justify-content: center !important;
    border-bottom: none !important;
  }
  /* Surrounding card shouldn't itself scroll */
  .card { overflow: hidden !important; }
}

/* ───────────────────────────────────────────────────────────────
   MOBILE TOPBAR — keep title + lang + indicator inside viewport.
   Earlier breakpoint pushed AR/EN button off-screen on phones.
   ─────────────────────────────────────────────────────────────── */
@media (max-width: 720px) {
  .topbar {
    flex-wrap: wrap;
    gap: 8px !important;
    padding: 10px 12px !important;
  }
  .topbar-left {
    flex: 1 1 auto;
    min-width: 0;
  }
  .topbar-title {
    font-size: 17px !important;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .topbar-subtitle {
    font-size: 11px !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
  }
  .topbar-right {
    flex-shrink: 0;
    display: flex;
    gap: 6px;
    align-items: center;
  }
  /* Realtime indicator: shrink */
  #rtIndicator {
    padding: 4px 8px !important;
    font-size: 10px !important;
  }
  /* AR (soon) — compact for narrow screens */
  .lang-switch,
  .lang-toggle {
    padding: 2px !important;
  }
  .lang-switch span,
  .lang-toggle span {
    padding: 4px 8px !important;
    font-size: 10px !important;
  }
  .lang-switch span.lang-disabled small,
  .lang-toggle span.lang-disabled small {
    display: inline !important;
    font-size: 8.5px !important;
    margin-inline-start: 2px;
    opacity: 0.85;
  }
}
@media (max-width: 380px) {
  .topbar-subtitle { display: none; }   /* drop subtitle on tiny phones */
}
