/* ================================================================
   TIDAL 手机端样式层  v1 (20261027)
   设计目标：保留 Cool Silver 浅色语言，只重排 <=1000px 的排版与导航
   加载位置：所有页面 </head> 之前，位于所有主题层之后（最后一层）
   作用域：会员后台 body.research-app 只补导航与表格，不重排版式
   ================================================================ */

:root {
  --m-ink: #0d2b45;
  --m-sub: #6b7684;
  --m-line: #e3e8ef;
  --m-accent: #0e7c86;
}

/* ---------- 0. 默认隐藏（桌面端不出现任何手机元素） ---------- */
.mnav-btn, .mnav-drawer, .mnav-mask { display: none; }

/* ---------- 1. 页头 + 汉堡入口（不含会员后台 topbar） ---------- */
@media (max-width: 1000px) {
  header:not(.member-top):not(.terminal-top) {
    height: 58px !important;
    min-height: 58px !important;
    padding: 0 14px !important;
    margin: 0 !important;
    border-radius: 0 !important;
    border-bottom: 1px solid var(--m-line) !important;
    background: rgba(255, 255, 255, .94) !important;
    -webkit-backdrop-filter: blur(18px) saturate(120%) !important;
    backdrop-filter: blur(18px) saturate(120%) !important;
    gap: 8px !important;
    flex-wrap: nowrap !important;
  }
  header:not(.member-top):not(.terminal-top) .brand { gap: 9px !important; }
  header:not(.member-top):not(.terminal-top) .brand-mark {
    width: 34px !important; height: 34px !important; flex: 0 0 34px !important;
    border-radius: 9px !important;
  }
  header:not(.member-top):not(.terminal-top) .brand-img { width: 34px !important; height: 34px !important; }
  header:not(.member-top):not(.terminal-top) .brand-word { font-size: 14px !important; letter-spacing: .1em !important; }
  header:not(.member-top):not(.terminal-top) .brand > small { display: none !important; }
  header:not(.member-top):not(.terminal-top) #accountActions { margin-left: auto !important; gap: 8px !important; }
  header:not(.member-top):not(.terminal-top) #accountActions button {
    height: 34px !important; min-height: 34px !important;
    padding: 0 13px !important; font-size: 12.5px !important;
    border-radius: 10px !important;
  }
  header:not(.member-top):not(.terminal-top) #accountActions .ghost { display: none !important; }

  /* 手机端统一走抽屉，页头内联导航一律收起（含 free/daily 的 .logo 页头） */
  header:not(.member-top):not(.terminal-top) nav { display: none !important; }
  header .logo, header .logo span, header .brand { white-space: nowrap !important; }
  header .logo span { font-size: 13.5px !important; letter-spacing: 0 !important; }
  header .logo img { width: 26px !important; height: 26px !important; }
  header .logo span b { margin-right: 5px; }

  /* 有 h1 的文档型页头（历史业绩 / 交易记录等）：改为上下结构，不再挤成一行 */
  header:not(.member-top):not(.terminal-top):has(h1) {
    height: auto !important;
    min-height: 0 !important;
    align-items: flex-start !important;
    flex-wrap: nowrap !important;
    gap: 10px !important;
    padding: 14px 14px 10px !important;
  }
  header:not(.member-top):not(.terminal-top):has(h1) img { width: 32px !important; height: 32px !important; border-radius: 9px !important; flex: 0 0 32px !important; }
  header:not(.member-top):not(.terminal-top):has(h1) h1 {
    font-size: 20px !important;
    line-height: 1.3 !important;
    letter-spacing: 0 !important;
    flex: 1 1 auto;
    min-width: 0;
  }
  header:not(.member-top):not(.terminal-top):has(h1) h1 small {
    display: block !important;
    font-size: 12px !important;
    line-height: 1.6 !important;
    margin-top: 4px !important;
    font-weight: 400 !important;
  }

  /* 汉堡按钮 */
  .mnav-btn {
    display: inline-flex !important;
    flex-direction: column; justify-content: center; align-items: center; gap: 4px;
    width: 40px; height: 40px; min-width: 40px; margin-left: 2px; padding: 0;
    border: 1px solid var(--m-line); border-radius: 11px;
    background: #fff; cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .mnav-btn:active { background: #f2f5f8; }
  .mnav-btn span { display: block; width: 17px; height: 1.8px; border-radius: 2px; background: var(--m-ink); }
  /* 浮动版（页面无 header / 会员后台密集顶栏）：右下角浮球 */
  .mnav-btn.mnav-float {
    position: fixed; right: 14px; bottom: calc(18px + env(safe-area-inset-bottom, 0px));
    z-index: 96; margin: 0;
    width: 48px; height: 48px; border-radius: 15px;
    border: 0; background: linear-gradient(135deg, #0d2b45, #0e7c86);
    box-shadow: 0 10px 26px rgba(13, 43, 69, .30);
  }
  .mnav-btn.mnav-float span { width: 19px; background: #fff; }

  /* 遮罩 + 抽屉 */
  .mnav-mask {
    display: block;
    position: fixed; inset: 0; z-index: 9900;
    background: rgba(8, 22, 30, .40);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    opacity: 0; pointer-events: none; transition: opacity .24s ease;
  }
  .mnav-mask.on { opacity: 1; pointer-events: auto; }
  .mnav-drawer {
    position: fixed; top: 0; right: 0; bottom: 0; z-index: 9901;
    width: min(86vw, 336px);
    background: #fff;
    border-radius: 20px 0 0 20px;
    box-shadow: -18px 0 60px rgba(13, 43, 69, .20);
    transform: translateX(102%);
    transition: transform .28s cubic-bezier(.22, .61, .36, 1);
    display: flex; flex-direction: column;
    padding: 14px 0 18px;
    font-family: inherit;
  }
  .mnav-drawer.on { transform: translateX(0); }
  .mnav-head {
    display: flex; align-items: center; gap: 10px;
    padding: 4px 16px 14px; border-bottom: 1px solid var(--m-line);
  }
  .mnav-head img { width: 30px; height: 30px; border-radius: 8px; display: block; }
  .mnav-head .mt { display: flex; flex-direction: column; line-height: 1.3; }
  .mnav-head b { font-size: 14px; letter-spacing: .12em; color: var(--m-ink); font-weight: 700; }
  .mnav-head small { font-size: 10.5px; color: var(--m-sub); letter-spacing: .04em; }
  .mnav-close {
    margin-left: auto; width: 34px; height: 34px; flex: 0 0 34px;
    border: 1px solid var(--m-line); border-radius: 10px; background: #fff;
    color: var(--m-sub); font-size: 17px; line-height: 1;
  }
  .mnav-list { padding: 6px 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .mnav-list a {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 18px; text-decoration: none !important;
    border-bottom: 1px solid #f2f5f8;
  }
  .mnav-list a:last-child { border-bottom: 0; }
  .mnav-list a:active { background: #f6f9fb; }
  .mnav-list a i {
    font-style: normal; font-size: 10px; color: var(--m-accent);
    letter-spacing: .1em; min-width: 18px; font-weight: 700;
  }
  .mnav-list a .tx { display: flex; flex-direction: column; }
  .mnav-list a .lb { font-size: 15px; color: var(--m-ink); font-weight: 600; }
  .mnav-list a .ds { display: block; font-size: 11.5px; color: var(--m-sub); font-weight: 400; margin-top: 1px; }
  .mnav-list a .ar { margin-left: auto; color: #c3ccd8; font-size: 15px; }
  .mnav-foot { padding: 14px 16px 0; border-top: 1px solid var(--m-line); margin-top: auto; }
  .mnav-foot button {
    width: 100%; height: 46px; border-radius: 12px; font-size: 15px; font-weight: 600;
    margin-bottom: 9px; border: 1px solid var(--m-line); background: #fff; color: var(--m-ink);
  }
  .mnav-foot button.primary {
    border: 0; color: #fff;
    background: linear-gradient(135deg, #0d2b45, #0e7c86);
  }
  body.mnav-open { overflow: hidden !important; }
}

/* ---------- 2. 排版体系（营销/内容页；会员后台不动） ---------- */
@media (max-width: 1000px) {
  html { -webkit-text-size-adjust: 100%; }
  body:not(.research-app) { font-size: 14px; line-height: 1.78; }
  body:not(.research-app) h1 { font-size: 30px !important; line-height: 1.28 !important; letter-spacing: -.005em !important; }
  body:not(.research-app) h2 { font-size: 23px !important; line-height: 1.36 !important; letter-spacing: 0 !important; }
  body:not(.research-app) h3 { font-size: 16px !important; line-height: 1.45 !important; }
  body:not(.research-app) p,
  body:not(.research-app) li { font-size: 14px !important; line-height: 1.8 !important; }
  body:not(.research-app) small,
  body:not(.research-app) .trust,
  body:not(.research-app) label,
  body:not(.research-app) .section-head p,
  body:not(.research-app) .terminal small,
  body:not(.research-app) .terminal .ticks span,
  body:not(.research-app) .stats article small,
  body:not(.research-app) .kpi small,
  body:not(.research-app) .hint { font-size: 12px !important; }
}

/* ---------- 3. 节奏与留白 ---------- */
@media (max-width: 1000px) {
  body:not(.research-app) section,
  body:not(.research-app) .section { padding-top: 40px !important; padding-bottom: 40px !important; }
  body:not(.research-app) .hero { padding-top: 26px !important; padding-bottom: 34px !important; }
  body:not(.research-app) .section-head { margin-bottom: 18px !important; gap: 8px !important; }
  body:not(.research-app) .section-head p { margin-top: 6px !important; }
  body:not(.research-app) .cards { gap: 12px !important; grid-template-columns: 1fr !important; }
  body:not(.research-app) .cards article {
    min-height: 0 !important;
    padding: 18px 18px 20px !important;
    border-radius: 16px !important;
  }
  body:not(.research-app) .hero .terminal { margin-top: 18px !important; border-radius: 18px !important; }
  body:not(.research-app) .stats { grid-template-columns: 1fr 1fr !important; gap: 10px !important; margin: 0 14px !important; }
  body:not(.research-app) .stats article { padding: 14px !important; border-radius: 14px !important; }
  body:not(.research-app) .stats article b { font-size: 19px !important; }
  body:not(.research-app) .manual-metrics { grid-template-columns: 1fr 1fr !important; gap: 10px !important; }
  body:not(.research-app) .manual-grid,
  body:not(.research-app) .manual-visuals,
  body:not(.research-app) .manual-combo,
  body:not(.research-app) .research-layout { grid-template-columns: 1fr !important; }
  body:not(.research-app) .bars { font-size: 20px !important; letter-spacing: 2px !important; }
  body:not(.research-app) .ring strong { font-size: 40px !important; }
}

/* ---------- 4. 表格：可横滑、不压扁 ---------- */
@media (max-width: 1000px) {
  body .table { display: block; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; font-size: 12.5px !important; }
  body .table th, body .table td { padding: 9px 10px !important; white-space: nowrap; }
  body th, body td, body td b, body th b, body td mark, body td .locked { font-size: 12.5px; }
  body .terminal span, body .terminal b,
  body .chart-title b, body .chart-title span, body .summary b, body .summary span,
  body .toolbar span, body .toolbar b, body .contact span { font-size: 12px !important; }
  body .combo-year b { font-size: 10px !important; letter-spacing: 0 !important; }
  body .combo-year { min-width: 0 !important; }
}

/* ---------- 5. 会员套餐：横向滑动卡片 ---------- */
@media (max-width: 1000px) {
  body .plans, body .tier-plans {
    display: flex !important;
    grid-template-columns: none !important;
    align-items: flex-start !important;
    gap: 12px !important;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding: 2px 14px 10px !important;
    margin-left: -14px;
    margin-right: -14px;
    scrollbar-width: none;
  }
  body .plans::-webkit-scrollbar, body .tier-plans::-webkit-scrollbar { display: none; }
  body .plans article, body .tier-plans article {
    flex: 0 0 82vw !important;
    align-self: flex-start;
    scroll-snap-align: start;
    min-height: 0 !important;
    padding: 22px 20px 20px !important;
    border-radius: 18px !important;
    display: flex !important;
    flex-direction: column !important;
  }
  body .plans article > button:last-child,
  body .tier-plans article > button:last-child { width: 100% !important; margin-top: 14px !important; }
  body .benefit-compare {
    overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 16px;
    box-shadow: inset -18px 0 16px -18px rgba(13, 43, 69, .28);
  }
  body .benefit-compare table { min-width: 800px; }
  body .benefit-compare th, body .benefit-compare td { white-space: nowrap !important; padding: 12px 14px !important; }
  body .benefit-compare th:first-child, body .benefit-compare td:first-child {
    position: sticky; left: 0; z-index: 2; background: #fff;
    box-shadow: 8px 0 12px -8px rgba(13, 43, 69, .18);
  }
}

/* ---------- 6. 锚点避开吸顶页头 ---------- */
@media (max-width: 1000px) {
  body section[id], body [id].section { scroll-margin-top: 70px; }
}

/* ---------- 7. 触控目标 ---------- */
@media (max-width: 1000px) {
  body:not(.research-app) .hero button,
  body:not(.research-app) .plans button,
  body:not(.research-app) .contact button,
  body:not(.research-app) .purchase-policy,
  body:not(.research-app) .paid-plan button {
    min-height: 48px !important; font-size: 15px !important; border-radius: 13px !important;
  }
}

/* ---------- 8. iOS：输入框字号 <16px 会触发 Safari 聚焦自动放大（且不自动还原） ---------- */
@media (max-width: 1000px) {
  body input, body select, body textarea { font-size: 16px !important; }
  body input[type="checkbox"], body input[type="radio"] { font-size: 14px !important; }
  body input[type="date"] { min-height: 42px; }
}

/* ---------- 9. 会员后台：横向滑动收敛到局部，吸顶栏不透明 ---------- */
@media (max-width: 1000px) {
  /* 9.1 先把可能撑宽页面的容器全部限死在视口内 */
  body.research-app .research-layout,
  body.research-app .research-main,
  body.research-app .research-side { max-width: 100% !important; min-width: 0 !important; }

  /* 9.2 功能导航：曾经 min-width:max-content 把页面撑到 1534px（整页横移的元凶），
         改成自身横向滑动，绝不再撑开父级 */
  body.research-app .function-switch {
    min-width: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    padding: 4px 2px 8px !important;
  }
  body.research-app .function-switch::-webkit-scrollbar { display: none; }
  body.research-app .function-switch > * { flex: 0 0 auto !important; }
  body.research-app .function-switch a,
  body.research-app .function-switch button {
    width: auto !important;
    margin: 0 3px !important;
    white-space: nowrap !important;
  }

  /* 9.3 吸顶栏改为不透明，内容不再从下面透出来 */
  body.research-app header.terminal-top {
    background: #fff !important;
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
    box-shadow: 0 1px 0 rgba(13, 43, 69, .07), 0 10px 18px -16px rgba(13, 43, 69, .45);
  }
  body.research-app .research-side {
    top: var(--mh, 108px) !important;
    background: #fff !important;
    box-shadow: 0 10px 16px -16px rgba(13, 43, 69, .55);
  }

  /* 9.4 账本表格：只在卡片里横滑；手机端业务表格改用卡片列表 */
  body.research-app #paperSection table {
    display: table !important;
    overflow: visible !important;
    max-width: none !important;
    font-size: 13px !important;
  }
  body.research-app #paperSection .pl-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    border-radius: 12px;
    background: #fff;
    margin: 8px 0 18px;
  }
  body.research-app #paperSection .pl-table-wrap table { min-width: 560px; margin: 0 !important; }
  body.research-app #paperSection .pl-table-wrap tr:last-child td { border-bottom: 0; }
}


/* ================================================================
   10. 弹窗可滚动（#auth 登录/注册、#app 会员终端）  2026-11-05
   ----------------------------------------------------------------
   问题：app.css 第 309 行那组超长选择器（.terminal,...,form,dialog）
   末尾带 overflow:hidden。它与文件开头 dialog{overflow:auto} 特异性
   相同（0,0,1）却更靠后，于是弹窗被判为"不可滚动"。
   实测 360x640：注册表单高 740px、弹窗可视 574px，底部「创建账户」
   被裁掉 166px，手指滑动无效 → 用户无法完成注册。
   修法：!important 复位纵向滚动；高度改用动态视口单位（dvh）+ JS
   兜底变量 --tidal-vh，避开手机浏览器地址栏/工具栏占位；内容短时
   仍是居中卡片；底部留出安全区。
   ================================================================ */
@media (max-width: 1000px) {
  dialog,
  dialog#auth,
  dialog#app {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
    height: auto !important;
    max-height: calc(var(--tidal-vh, 100vh) - 20px) !important;
    max-height: calc(100dvh - 20px) !important;
    width: calc(100vw - 20px) !important;
    max-width: 520px;
    padding: 20px 16px calc(20px + env(safe-area-inset-bottom, 0px)) !important;
    border-radius: 16px !important;
    scroll-padding-block: 14px 26px;
  }

  /* 关闭按钮保持原绝对定位：sticky 在滚动后会压住「登录/注册」标签。
     长表单滚到底时的退路是点遮罩关闭（逻辑在 mobile_nav.js 里委托）。 */
  dialog h3 { padding-right: 36px; }

  /* 条款勾选：多行文字改为顶对齐，避免与复选框错行 */
  dialog .check {
    align-items: flex-start !important;
    gap: 9px !important;
    line-height: 1.62;
  }
  dialog .check input { margin: 3px 0 0 !important; flex: 0 0 auto; }

  /* 窄屏收紧内边距，减少必然溢出 */
  dialog .auth-tabs { margin-top: 14px !important; }
  dialog .auth-hint { padding: 8px 10px !important; font-size: 12px !important; line-height: 1.62 !important; }
  dialog form { padding: 14px 12px !important; gap: 10px !important; }
}


/* 全局（含桌面）：app.css 第 309 行那组超长选择器里的 overflow:hidden
   是给卡片做圆角裁切用的，却把 dialog 也算进去了。窗口高度不足时
   （如 1280x720），注册表单底部同样会被裁掉且无法滚动。这里一并复位。 */
dialog#auth,
dialog#app {
  overflow-y: auto !important;
}


/* 会员页信号详情弹窗（.signal-detail-dialog 是自建 div 遮罩，不是原生 dialog）
   它本身是「固定头 + body 内部滚动」的正确结构，但高度写死 100vh，
   手机浏览器地址栏占位时底部会被顶出屏幕。统一改用动态视口高度。 */
@media (max-width: 1000px) {
  .signal-detail-dialog {
    max-height: calc(var(--tidal-vh, 100vh) - 22px) !important;
    max-height: calc(100dvh - 22px) !important;
  }
}

/* [2026-11-05] 翻页控件统一右对齐：入场建议/密切观察/离场建议的首尾翻页保持一致 */
.pager,.pager-top,.pager-bottom{justify-content:flex-end!important}
@media(max-width:620px){.pager,.pager-top,.pager-bottom{justify-content:flex-end!important}}

/* ============================================================
   导航精简（2026-11-06 nav1）：≤1000px 胶囊行只保留核心 5 项 + 「更多」
   其余功能收进底部抽屉 .fnsheet（member_nav_patch.js 注入）
   ============================================================ */
@media (max-width:1000px){
  body.research-app .function-switch .nav-group-label{display:none!important}
  body.research-app .function-switch button:not([data-core]):not(.fn-more){display:none!important}
  body.research-app .function-switch a.nav-daily{display:none!important}
  body.research-app .function-switch button.fn-primary{display:inline-flex!important}
  body.research-app .function-switch .fn-more{
    display:inline-flex!important;align-items:center;
    background:var(--wash);color:var(--cyan);
    box-shadow:inset 0 0 0 1px rgba(11,114,133,.14);
  }
  body.research-app .function-switch .nav-count{margin-left:6px}
}
