/* admin/src/css/mobile.css — 移动端独立交互层（docs/196）
 *
 * 生效条件：<html class="m-app">。该类只由 mobile.js 在真实手机上添加，
 * 桌面浏览器永远不会带上，因此本文件对 web 端的视觉效果为零影响。
 *
 * 规则全部带 html.m-app 前缀且晚于 admin.css 加载，用于覆盖历史三套
 * 移动端规则（≤920 抽屉 / ≤768 底部 Tab / ≤640 弹窗 / docs/152 补丁）。
 * 布局目标：视口锁死，页面本身不滚不溢出，只有列表与弹层内部滚动。
 */
html.m-app, html.m-app body {
  width: 100%; max-width: 100vw; height: 100%; min-height: 0;
  margin: 0; overflow: hidden; overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}
html.m-app body { background: #f5f6f8; background-attachment: scroll; }
html.m-app .app-view {
  position: fixed !important; inset: 0 !important;
  height: 100dvh !important; min-height: 0 !important;
  flex-direction: column !important; overflow: hidden;
  background: #f5f6f8;
}
html.m-app .sidebar,
html.m-app #drawer-mask,
html.m-app .topbar { display: none !important; }
html.m-app .main {
  flex: 1 1 auto !important; min-height: 0 !important; width: 100% !important;
  display: flex; flex-direction: column;
}
/* 唯一滚动容器：所有列表内容都在这里滚，body 永不滚 */
html.m-app .content {
  flex: 1 1 auto !important; min-height: 0 !important;
  overflow-y: auto !important; overflow-x: hidden !important;
  -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  padding: 10px 10px calc(16px + env(safe-area-inset-bottom)) !important;
}

/* ---------- 登录：整屏居中，键盘弹起时自己滚 ---------- */
html.m-app #login-view {
  position: fixed; inset: 0; overflow-y: auto; overscroll-behavior: contain;
  align-items: center; justify-content: center;
  padding: calc(20px + env(safe-area-inset-top)) 18px calc(20px + env(safe-area-inset-bottom));
}
html.m-app .login-card { width: 100%; max-width: 420px; margin: auto; padding: 26px 20px; border-radius: 18px; }
html.m-app .login-card input { font-size: 16px; }

/* ---------- 顶部：跟踪池标题 + 日期 / 数量 + 刷新 ---------- */
html.m-app #m-head {
  flex: 0 0 auto; height: calc(54px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 12px 0;
  display: flex; align-items: center; gap: 10px;
  background: #fff; border-bottom: 1px solid #e8e6e1; z-index: 30;
}
html.m-app .m-brand { display: flex; align-items: center; gap: 9px; min-width: 0; flex: 1; }
html.m-app .m-mark {
  flex: 0 0 auto; width: 30px; height: 30px; border-radius: 9px;
  display: grid; place-items: center; font-size: 15px; font-weight: 800; color: #fff;
  background: linear-gradient(135deg, #d4af37, #a97c12);
}
html.m-app .m-txt { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
html.m-app .m-txt b { font-size: 15px; color: #1f2937; white-space: nowrap; }
html.m-app .m-txt small {
  font-size: 11px; color: #8a8f98; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; max-width: 100%;
}
html.m-app .m-icon {
  flex: 0 0 auto; width: 40px; height: 40px; border: 0; border-radius: 12px;
  display: grid; place-items: center; background: #f6f4ee; color: #8a6a15;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
html.m-app .m-icon svg { width: 20px; height: 20px; }
html.m-app .m-icon.spin svg { animation: m-spin .8s linear infinite; }
@keyframes m-spin { to { transform: rotate(360deg); } }

/* ---------- 当前筛选条：吸顶，点开筛选面板 ---------- */
html.m-app #m-active {
  position: sticky; top: 0; z-index: 12;
  display: flex; align-items: center; gap: 8px; margin: 0 0 10px;
  padding: 10px 12px; border: 1px solid #e8e6e1; border-radius: 12px;
  background: rgba(255, 255, 255, .96); backdrop-filter: blur(8px);
  font-size: 12.5px; color: #4b5563; min-height: 42px;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
html.m-app #m-active span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
html.m-app #m-active i { flex: 0 0 auto; font-style: normal; color: #b8860b; font-weight: 700; }

/* ---------- 下拉刷新提示 ---------- */
html.m-app #m-ptr {
  position: fixed; left: 0; right: 0; top: calc(54px + env(safe-area-inset-top));
  z-index: 25; display: flex; justify-content: center;
  pointer-events: none; opacity: 0; transition: opacity .15s;
}
html.m-app #m-ptr.on { opacity: 1; }
html.m-app #m-ptr span {
  background: rgba(30, 41, 59, .84); color: #fff; border-radius: 999px;
  padding: 6px 14px; font-size: 12px;
}

/* ---------- 只留跟踪池卡片：其余 AI 选股页元素全部隐藏 ---------- */
html.m-app #aipick-panel {
  display: flex !important; flex-direction: column; gap: 0;
  min-height: 0; width: 100%; max-width: 100%;
}
html.m-app #aipick-panel > :not(section.ap2-card):not(.ap2-whybar) { display: none !important; }
/* ---------- 搜索条保留（原「分析未入选原因」：代码 / 名称 → 打开详情并定位到「为什么没选」） ---------- */
html.m-app .ap2-whybar {
  display: flex !important; align-items: center; gap: 8px; margin: 0 0 10px;
  position: sticky; top: 52px; z-index: 11; padding: 0 0 8px; /* 吸在「当前筛选条」下方 */
  background: #f5f6f8;
}
html.m-app .ap2-whybox { flex: 1 1 auto; min-width: 0; }
html.m-app #ap2-why-input { height: 42px; font-size: 16px; /* 16px 防 iOS 聚焦自动放大 */ border-radius: 12px; }
html.m-app .ap2-why-ico { left: 12px; }
html.m-app .ap2-why-clear { min-width: 36px; min-height: 36px; }
html.m-app #ap2-why-btn { flex: 0 0 auto; min-height: 42px; padding: 0 14px; border-radius: 12px; white-space: nowrap; }
html.m-app .ap2-why-sug { top: 46px; max-height: 40dvh; }
html.m-app .ap2-card {
  width: 100%; max-width: 100%; min-width: 0; overflow: hidden;
  border: 1px solid #e8e6e1; border-radius: 14px; padding: 0;
  box-shadow: 0 2px 12px rgba(15, 23, 42, .04);
}
html.m-app .ap2-card-head,
html.m-app .ap2-card-foot { display: none !important; }
html.m-app #ap2-watch-lag,
html.m-app #ap2-watch-delta { max-width: 100%; overflow: hidden; word-break: break-word; }
html.m-app #ap2-watch-delta * { white-space: normal !important; }
html.m-app #ap2-watch-grid {
  display: grid !important; grid-template-columns: minmax(0, 1fr) !important;
  gap: 10px; padding: 10px !important;
}
html.m-app #ap2-watch-table-wrap { display: none !important; }
html.m-app .ap2-wcard {
  max-width: 100%; overflow: hidden; border-radius: 12px; padding: 12px; gap: 7px;
}
html.m-app .ap2-wcard * { min-width: 0; }
html.m-app .ap2-wc-tags > * { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
html.m-app .ap2-wk { height: 104px; }
html.m-app .ap2-wgrid-empty { padding: 36px 12px; }

/* ---------- 详情：全屏页 + 返回，内部滚动 ---------- */
html.m-app #ap2-drawer-mask {
  position: fixed !important; inset: 0 !important; padding: 0 !important;
  z-index: 3000 !important; align-items: stretch !important; justify-content: stretch !important;
  background: rgba(15, 23, 42, .35);
}
html.m-app #ap2-drawer {
  width: 100vw !important; max-width: 100vw !important;
  height: 100dvh !important; max-height: 100dvh !important;
  border: none !important; border-radius: 0 !important; margin: 0 !important;
  overflow: hidden;
}
html.m-app .ap2-drawer-head {
  flex: 0 0 auto; padding: calc(10px + env(safe-area-inset-top)) 12px 10px;
  background: #fff; border-bottom: 1px solid #e8e6e1;
}
html.m-app .ap2-d-title { font-size: 15px; }
html.m-app #ap2-d-close { display: none !important; }
html.m-app #m-d-back {
  display: inline-flex; align-items: center; gap: 2px; min-height: 40px;
  padding: 0 10px 0 6px; border: 0; border-radius: 10px;
  background: #f6f4ee; color: #8a6a15; font-size: 13px; font-weight: 700;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
html.m-app #m-d-back svg { width: 18px; height: 18px; }
html.m-app #ap2-d-body {
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto; overflow-x: hidden;
  -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  padding: 12px 12px calc(28px + env(safe-area-inset-bottom));
}
html.m-app #ap2-d-body table { min-width: 0 !important; max-width: 100% !important; }
/* 详情区几个桌面定宽栅格（380 / 210 / 165px）在 390px 屏上会撑出容器 */
html.m-app #ap2-d-body .ap2-dv-gates,
html.m-app #ap2-d-body .ap2-dg-dims,
html.m-app #ap2-d-body .ap2-fd-grid { grid-template-columns: minmax(0, 1fr) !important; }
html.m-app #ap2-d-chart { width: 100% !important; }
/* 总览 / 手册只在 web 端使用，手机端不提供入口也不显示 */
html.m-app #ap2-ov-mask,
html.m-app #ap2-manual-mask { display: none !important; }

/* ---------- 底部动作条 ---------- */
html.m-app #m-bar {
  flex: 0 0 auto; height: calc(58px + env(safe-area-inset-bottom));
  padding: 0 6px env(safe-area-inset-bottom);
  display: flex; background: #fff; border-top: 1px solid #e8e6e1; z-index: 30;
}
html.m-app #m-bar button {
  flex: 1; min-width: 0; min-height: 44px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border: 0; background: transparent; color: #8a8f98; font-size: 11px;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
html.m-app #m-bar button svg { width: 20px; height: 20px; }
html.m-app #m-bar button.on { color: #b8860b; font-weight: 700; }

/* ---------- 底部面板：筛选 / 排序 / 更多 ---------- */
html.m-app #m-mask {
  position: fixed; inset: 0; z-index: 4000;
  background: rgba(15, 23, 42, .42); display: none;
}
html.m-app #m-mask.on { display: block; }
html.m-app #m-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 4001;
  max-height: min(78dvh, 640px); display: flex; flex-direction: column; overflow: hidden;
  background: #fff; border-radius: 18px 18px 0 0;
  box-shadow: 0 -12px 36px rgba(15, 23, 42, .18);
  transform: translateY(105%); transition: transform .22s ease;
}
html.m-app #m-sheet.on { transform: translateY(0); }
html.m-app .m-sheet-head {
  flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 10px; border-bottom: 1px solid #eee;
}
html.m-app .m-sheet-head b { font-size: 15px; color: #1f2937; }
html.m-app .m-sheet-head button {
  width: 36px; height: 36px; border: 0; border-radius: 10px;
  background: #f4f4f5; color: #6b7280; display: grid; place-items: center;
}
html.m-app .m-sheet-head button svg { width: 18px; height: 18px; }
html.m-app .m-sheet-body {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden;
  -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  padding: 14px 16px calc(20px + env(safe-area-inset-bottom));
}
html.m-app .m-pane { display: none; }
html.m-app .m-pane.on { display: block; }
html.m-app .m-sec-title {
  font-size: 12px; font-weight: 700; color: #8a6a15; margin: 2px 0 10px;
}
html.m-app .m-sec-title:not(:first-child) { margin-top: 20px; }
/* 复用 web 端原生筛选 DOM，改成换行铺开、大触控区，绝不横向滚动 */
html.m-app #m-filter-pane .ap2-filter-bar,
html.m-app #m-filter-pane .ap2-sector-filter {
  display: flex !important; flex-wrap: wrap !important; align-items: center !important;
  gap: 8px !important; grid-auto-flow: row !important; grid-template-rows: none !important;
  max-height: none !important; overflow: visible !important;
  white-space: normal !important; padding: 0 !important; border: 0 !important;
}
html.m-app #m-filter-pane .ap2-sector-filter > * { white-space: normal !important; }
html.m-app #m-filter-pane .ap2-filter-bar > .ap2-filter-label,
html.m-app #m-filter-pane .ap2-sector-filter > .ap2-filter-label { display: none !important; }
html.m-app #m-filter-pane .ap2-mode-tab,
html.m-app #m-filter-pane .ap2-sf-chip,
html.m-app #m-filter-pane .ap2-sf-clear {
  min-height: 38px !important; padding: 6px 12px !important; font-size: 13px !important;
  border-radius: 999px !important; touch-action: manipulation;
}
html.m-app #m-filter-pane .ap2-ov-slot,
html.m-app #m-filter-pane [data-overview] { display: none !important; }
html.m-app #m-filter-pane #m-reset { margin-top: 18px; }
html.m-app .m-opt {
  display: block; width: 100%; min-height: 50px; margin-bottom: 10px;
  padding: 10px 14px; text-align: left;
  border: 1px solid #e8e6e1; border-radius: 12px; background: #fff;
  font-size: 14px; color: #1f2937; touch-action: manipulation;
}
html.m-app .m-opt small { display: block; margin-top: 2px; font-size: 11.5px; color: #8a8f98; font-weight: 400; }
html.m-app .m-opt.on { border-color: #b8860b; background: #fff8e8; color: #8a6a15; font-weight: 700; }
html.m-app .m-note {
  font-size: 12px; line-height: 1.75; color: #6b7280;
  background: #f8f7f4; border-radius: 10px; padding: 12px; margin: 4px 0 14px;
}

/* ---------- 兜底：任何内容都不许把页面撑出屏幕 ---------- */
html.m-app .content, html.m-app .content *,
html.m-app #ap2-d-body, html.m-app #ap2-d-body * {
  max-width: 100%; word-break: break-word;
}
html.m-app .content img, html.m-app #ap2-d-body img { max-width: 100%; height: auto; }
html.m-app #app-error-bar {
  position: fixed; top: calc(54px + env(safe-area-inset-top)); left: 0; right: 0;
  z-index: 5000;
}
