/* qt_mobile.css — پیام ۴۲ (۱۴۰۵/۰۸/۰۵): لایهٔ نمایش موبایل و تبلت. فقط CSS نمایشی؛ هیچ محاسبه، داده یا API تغییر نمی‌کند.
   سازگار با iOS Safari و Android Chrome: بدون اتکا به قابلیت‌های جدید (dvh با بازگشت به vh، safe-area با بازگشت به مقدار ثابت).
   خاموش‌کردن فوری: افزودن ?ui=1 به نشانی صفحه (کلاس qt-m0 روی html گذاشته می‌شود و این برگه بی‌اثر می‌شود). */

/* ---- جدول‌های عریض (در همهٔ عرض‌ها، از جمله دسکتاپ): درون ظرف اسکرول خودشان؛ ظرف را qt_mobile.js دور جدول می‌گذارد ---- */
.qt-tw { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
.qt-tw > table { min-width: 100%; }

/* ---- دکمهٔ همبرگر و پس‌زمینهٔ تیره: در دسکتاپ پنهان ---- */
#qt-menu-btn { display: none; }
#qt-backdrop { display: none; }

@media (max-width: 920px) {
  html:not(.qt-m0) { -webkit-text-size-adjust: 100%; }
  html:not(.qt-m0) body { min-width: 0; }
  html:not(.qt-m0) .app { display: block; min-height: 100vh; }
  html:not(.qt-m0) .main { width: 100%; max-width: 100%; min-width: 0; }

  /* ---- منوی کشویی (از راست، چون RTL) ---- */
  html:not(.qt-m0) .sidebar {
    position: fixed; top: 0; right: 0; bottom: auto; height: 100vh; height: 100dvh;
    width: min(300px, 86vw) !important; max-width: 86vw;
    transform: translateX(105%); visibility: hidden;
    transition: transform .22s ease, visibility 0s linear .22s;
    z-index: 300; box-shadow: none; overflow-y: auto; -webkit-overflow-scrolling: touch;
    padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  html:not(.qt-m0).qt-menu-open .sidebar { transform: none; visibility: visible; transition-delay: 0s; box-shadow: -8px 0 32px rgba(0,0,0,.35); }
  html:not(.qt-m0) .sidebar .sidebar-toggle { display: none; }
  html:not(.qt-m0) .sidebar-nav { overflow: visible; }
  /* حالت «جمع‌شده»ی دسکتاپ روی موبایل بی‌اثر است */
  html:not(.qt-m0) .sidebar.collapsed .sidebar-logo .word { opacity: 1; width: auto; }
  html:not(.qt-m0) .sidebar.collapsed .nav-item .label,
  html:not(.qt-m0) .sidebar.collapsed .nav-item .soon { opacity: 1; width: auto; }
  html:not(.qt-m0) .sidebar.collapsed .nav-item { justify-content: flex-start; padding: 10px 12px; }
  html:not(.qt-m0) .sidebar.collapsed .sidebar-search { display: flex; }
  html:not(.qt-m0) .sidebar.collapsed .sidebar-foot { opacity: 1; }
  html:not(.qt-m0) .sidebar.collapsed .nav-item::after { display: none; }
  html:not(.qt-m0) .nav-item { min-height: 48px; font-size: 15px; }
  html:not(.qt-m0) .sidebar-search input { min-height: 44px; }
  html:not(.qt-m0) .sidebar-search button { min-height: 44px; min-width: 64px; }

  html:not(.qt-m0).qt-menu-open #qt-backdrop {
    display: block; position: fixed; inset: 0; background: rgba(2,6,12,.55); z-index: 290; -webkit-tap-highlight-color: transparent;
  }
  html:not(.qt-m0).qt-menu-open, html:not(.qt-m0).qt-menu-open body { overflow: hidden; }

  /* ---- نوار بالایی ---- */
  html:not(.qt-m0) .topbar {
    padding: 8px max(12px, env(safe-area-inset-right, 0px)) 8px max(12px, env(safe-area-inset-left, 0px));
    gap: 10px; justify-content: flex-start;
  }
  html:not(.qt-m0) #qt-menu-btn {
    display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
    width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg-card); color: var(--text-primary);
    cursor: pointer; padding: 0; -webkit-tap-highlight-color: transparent;
  }
  html:not(.qt-m0) #qt-menu-btn svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; pointer-events: none; }
  html:not(.qt-m0) .topbar h1 { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; font-size: 17px; }
  html:not(.qt-m0) .topbar .live-status { flex: 0 0 auto; }

  /* ---- نوار پالس بازار (تیکر): نمایش داده می‌شود، بیرون‌زدگی ندارد ---- */
  html:not(.qt-m0) .pulse-strip { max-width: 100%; }

  /* ---- محتوا ---- */
  html:not(.qt-m0) .view { padding: 16px max(12px, env(safe-area-inset-right, 0px)) 48px max(12px, env(safe-area-inset-left, 0px)); max-width: 100%; }
  html:not(.qt-m0) .panel { margin-bottom: 20px; }
  html:not(.qt-m0) .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  html:not(.qt-m0) .index-strip, html:not(.qt-m0) .gl-grid { grid-template-columns: minmax(0, 1fr); }
  html:not(.qt-m0) .gl-grid > * { min-width: 0; }
  html:not(.qt-m0) .index-card { flex-wrap: wrap; gap: 6px 12px; min-width: 0; }
  html:not(.qt-m0) .index-card .val-block { min-width: 0; }
  html:not(.qt-m0) .profile-header { gap: 10px; }
  html:not(.qt-m0) .profile-header > * { min-width: 0; }
  html:not(.qt-m0) .profile-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  html:not(.qt-m0) img, html:not(.qt-m0) canvas, html:not(.qt-m0) svg { max-width: 100%; }
  html:not(.qt-m0) pre, html:not(.qt-m0) code { white-space: pre-wrap; word-break: break-word; }

  html:not(.qt-m0) table { font-size: 13px; }
  html:not(.qt-m0) thead th { font-size: 13px; padding: 10px 12px; }
  html:not(.qt-m0) tbody td { font-size: 13px; padding: 10px 12px; }

  /* ---- نوار تب‌ها: قابل کشیدن با انگشت و چسبیدن به تب ---- */
  html:not(.qt-m0) .profile-tabs, html:not(.qt-m0) .options-tabs, html:not(.qt-m0) .tabs, html:not(.qt-m0) .screener-subnav {
    flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain;
    scroll-snap-type: x proximity; scrollbar-width: none; max-width: 100%;
  }
  html:not(.qt-m0) .profile-tabs::-webkit-scrollbar, html:not(.qt-m0) .options-tabs::-webkit-scrollbar,
  html:not(.qt-m0) .tabs::-webkit-scrollbar, html:not(.qt-m0) .screener-subnav::-webkit-scrollbar { display: none; }
  html:not(.qt-m0) .profile-tabs > *, html:not(.qt-m0) .options-tabs > *, html:not(.qt-m0) .tabs > *, html:not(.qt-m0) .screener-subnav > * {
    flex: 0 0 auto; scroll-snap-align: center; white-space: nowrap; min-height: 44px;
  }
  html:not(.qt-m0) .profile-tab-btn { padding: 10px 14px; }

  /* ---- هدف‌های لمسی و ورودی‌ها ---- */
  html:not(.qt-m0) button, html:not(.qt-m0) select, html:not(.qt-m0) summary,
  html:not(.qt-m0) .tab-btn, html:not(.qt-m0) .screener-sub-btn, html:not(.qt-m0) [role="button"] { min-height: 44px; }
  html:not(.qt-m0) button, html:not(.qt-m0) [role="button"] { min-width: 44px; }
  html:not(.qt-m0) input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="range"]), html:not(.qt-m0) select, html:not(.qt-m0) textarea {
    min-height: 44px; font-size: 16px !important; /* جلوگیری از بزرگ‌نمایی خودکار iOS هنگام فوکوس */
  }
  html:not(.qt-m0) input[type="checkbox"], html:not(.qt-m0) input[type="radio"] { width: 22px; height: 22px; }
  html:not(.qt-m0) label { min-height: 36px; }
  html:not(.qt-m0) button, html:not(.qt-m0) select { font-size: 14px; } /* پیش‌فرض مرورگر ۱۳٫۳px است؛ کلاس‌های دارای اندازهٔ صریح بی‌تغییر می‌مانند */
  html:not(.qt-m0) a, html:not(.qt-m0) button { -webkit-tap-highlight-color: rgba(13,148,136,.18); }
}

@media (max-width: 640px) {
  /* نوار گروه‌ها (.pulse-strip، امتیاز گروه‌ها) روی موبایل پنهان؛ تیکر نمادها (#qt-ticker) می‌ماند — تصمیم مالک */
  html:not(.qt-m0) .pulse-strip { display: none; }
  html:not(.qt-m0) .stat-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
  html:not(.qt-m0) .ai-hero-content { padding: 22px 16px; }
}

@media (max-width: 700px) {
  /* شبکه‌های دارای حداقل ستون ۳۰۰px و بیشتر (استایل درون‌خطی یا .ex-grid) روی عرض باریک تک‌ستونه می‌شوند */
  html:not(.qt-m0) .ex-grid, html:not(.qt-m0) [style*="minmax(3"] { grid-template-columns: minmax(0, 1fr) !important; }
}

/* ---- قاب نمودار در پروفایل: هرگز از عرض صفحه بیرون نمی‌زند ---- */
iframe[data-qt-lw] { max-width: 100%; }
