/* ============================================================
   移动端布局（APP / 手机浏览器）
   策略：不改 JS、不改页面结构，只把「左侧导航」重排为「底部 Tab」。
   - 桌面端（>820px）完全不受影响
   - 导航项文字用 data-short 显示短名，避免 5 个字挤成两行
   ============================================================ */

@media (max-width: 820px) {

  /* ---------- 解除桌面端最小宽度 ----------
   * main.css 给 body 设了 min-width:1100px（桌面三栏设计的底线）。
   * 窄屏下若不清零，body 仍是 1100px 宽，页面右侧内容会被屏幕边缘**截断**
   * （卡片说明文字、输入框右半边看不见），底部 Tab 虽已生效但内容区照样溢出。
   * v26111102 补上这一条，是移动端可读的前提。 */
  html, body { min-width: 0; }

  /* ---------- 统计卡片：4 列 → 2 列 ----------
   * main.css 的 .stat-grid 写死 repeat(4,1fr)，1fr 的最小宽度是 min-content
   * （图标 + 数字 + 不换行的标签），单卡约 115px。4 列 + 间距 = 506px，
   * 窄屏下把首页整体顶宽到 506px，出现横向滚动（v26111103 修复）。 */
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 10px 12px; gap: 8px; border-left-width: 4px; }
  .stat-card .stat-icon { font-size: 18px; }
  .stat-card .stat-num { font-size: 22px; }
  .stat-card .stat-label { font-size: 11px; }

  /* ---------- 顶栏压缩 ----------
   * 🔴 血案（v26111401 实测）：main.css 把 .topnav 写死 height:64px，而 .topnav-right
   *    里 6 个元素在 390px 宽下会换行到 124px 高、上边距 -31px —— 直接溢出压到页面上，
   *    标题被挤成 86px 宽、十个字逐个竖排，整条顶栏糊成一团（用户截图实证）。
   *    解法：高度改自适应 + 禁止换行 + 标题单行省略 + 按钮缩小 + 砍掉非必要入口。 */
  .topnav {
    height: auto;
    min-height: 54px;
    padding: 7px 10px;
    gap: 8px;
    flex-wrap: nowrap;
  }
  .topnav-logo { flex: 1 1 auto; min-width: 0; gap: 6px; }
  .topnav-logo svg { width: 26px; height: 26px; flex: 0 0 auto; }
  .topnav-title {
    font-size: 14px;
    letter-spacing: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
  }
  .topnav-slogan { display: none; }
  .topnav-streak { display: none; }
  .nav-toggle { display: none; }   /* 底部已有 Tab，不再需要折叠按钮 */
  .topnav-right {
    flex: 0 0 auto;
    flex-wrap: nowrap;
    gap: 5px;
    font-size: 12px;
  }
  .topnav-right .btn-sm {
    padding: 4px 8px;
    font-size: 11.5px;
    white-space: nowrap;
  }
  #topAccountActions { gap: 5px !important; }
  /* 云同步给页面内入口，顶栏让位给标题与登录/会员 */
  #topCloudSyncBtn { display: none !important; }
  /* 「试用已结束 / 免费试用 剩 N 天」要留（转化信息），但 13px + 左右各 12px 内边距
     在线上占掉 ~100px，把标题压到 49px（真机实测）。缩成 10px 小标签。 */
  #topCloudBizStatus,
  .topnav .cloudbiz-status {
    font-size: 10px !important;
    padding: 2px 7px !important;
    white-space: nowrap;
    max-width: 96px;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 15px;
  }
  /* 手机上退出登录极少用，且和「登录」互斥占位；收进「我的」页面 */
  #topLogoutBtn { display: none !important; }
  /* 组织入口在手机上让位：顶栏放不下 4 个按钮 */
  #topOrgBtn { display: none !important; }

  /* ---------- 主体：单列 ---------- */
  .layout {
    display: block;
    /* 顶栏已改成自适应高度（min-height:54px），不能再按 --topnav-h(64px) 算 */
    min-height: calc(100vh - 54px);
  }
  .content {
    padding: 12px 12px calc(64px + env(safe-area-inset-bottom, 0px));
    max-width: 100%;
  }

  /* ---------- 左导航 → 底部 Tab ---------- */
  .sidenav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    flex-direction: row;
    padding: 0 0 env(safe-area-inset-bottom, 0px);
    background: var(--bg-container);
    border-right: none;
    border-top: 1px solid var(--border-base);
    box-shadow: 0 -2px 12px rgba(15, 76, 58, .08);
    z-index: 200;
  }
  .sidenav.collapsed { width: 100%; }
  .sidenav.collapsed .sidenav-text { display: block; }

  .sidenav-item {
    flex: 1 1 0;
    min-width: 0;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    min-height: 56px;
    padding: 6px 2px;
    border-left: none;
    border-top: 3px solid transparent;
    text-align: center;
  }
  .sidenav-item.active {
    background: transparent;
    border-left-color: transparent;
    border-top-color: var(--accent-500);
  }
  .sidenav-icon { font-size: 19px; width: auto; }

  /* 用 data-short 显示短名，原文案隐藏（语义仍在 DOM 里） */
  .sidenav-text { font-size: 0; line-height: 1.1; }
  .sidenav-text::after {
    content: attr(data-short);
    font-size: 10px;
  }

  .sidenav-sep,
  .sidenav-minor { display: none !important; }

  /* 底部状态条让位给 Tab */
  .bottombar { display: none; }

  /* ---------- 内容容器收紧 ---------- */
  .card { padding: 12px 14px; }
  .page-title { margin-bottom: 14px; }
  .page-title h1 { font-size: 20px; }
}

/* 极小屏（360px 及以下） */
@media (max-width: 380px) {
  .sidenav-text::after { font-size: 9px; }
  .content { padding-left: 10px; padding-right: 10px; }
}
