/* ============================================================
 * 汇游推广数据助手（手机版）响应式适配
 * 仅在窄屏（<= 860px）生效，不影响桌面浏览器查看
 * ============================================================ */

/* 手机通知开关按钮（bridge.js 创建，桌面/手机通用） */
#push-fab {
  position: fixed; left: 14px; bottom: calc(92px + env(safe-area-inset-bottom));
  z-index: 9800;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  cursor: pointer; user-select: none;
  -webkit-tap-highlight-color: transparent;
}
#push-fab .pfab-bell {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: #fff; font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 18px rgba(37, 99, 235, .4);
  transition: transform .12s;
}
#push-fab:active .pfab-bell { transform: scale(.92); }
#push-fab .pfab-tip { display: none; }
#push-fab.pfab-on .pfab-bell { background: linear-gradient(135deg, #059669, #10b981); box-shadow: 0 6px 18px rgba(5, 150, 105, .4); }

/* 后台守护开关按钮（bridge.js 创建，位于铃铛上方） */
#guard-fab {
  position: fixed; left: 14px; bottom: calc(158px + env(safe-area-inset-bottom));
  z-index: 9790;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  cursor: pointer; user-select: none;
  -webkit-tap-highlight-color: transparent;
}
#guard-fab .gfab-shield {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, #b45309, #d97706);
  color: #fff; font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 18px rgba(217, 119, 6, .4);
  transition: transform .12s;
}
#guard-fab:active .gfab-shield { transform: scale(.92); }
#guard-fab .gfab-tip { display: none; }
#guard-fab.gfab-on .gfab-shield { background: linear-gradient(135deg, #059669, #10b981); box-shadow: 0 6px 18px rgba(5, 150, 105, .4); }
#guard-fab.gfab-err .gfab-shield { background: linear-gradient(135deg, #dc2626, #ef4444); box-shadow: 0 6px 18px rgba(220, 38, 38, .45); }

/* 后台守护面板 */
#guard-panel, #push-panel {
  position: fixed; left: 0; right: 0; bottom: 0;
  width: 100%; max-width: 420px; margin: 0 auto;
  z-index: 9860;
  background: linear-gradient(180deg, #1e2740, #151b2c);
  color: #e5edf8;
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -12px 40px rgba(2, 8, 23, .6);
  padding: 18px 16px calc(20px + env(safe-area-inset-bottom));
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  box-sizing: border-box;
}
#guard-panel .gp-head, #push-panel .gp-head { font-size: 15px; font-weight: 700; display: flex; align-items: baseline; gap: 8px; margin-bottom: 12px; }
#guard-panel .gp-sub, #push-panel .gp-sub { font-size: 11px; font-weight: 400; color: #93a4c8; }
#guard-panel .gp-code, #push-panel .gp-code {
  margin-bottom: 4px; padding: 8px 10px; border-radius: 8px;
  background: rgba(217, 119, 6, .12); border: 1px solid rgba(217, 119, 6, .35);
  color: #fcd34d; font-size: 12px; line-height: 1.6;
}
#guard-panel .gp-row, #push-panel .gp-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid rgba(255, 255, 255, .08); }
#guard-panel .gp-name, #push-panel .gp-name { flex: none; width: 64px; font-size: 13px; color: #b9c6e0; }
#guard-panel .gp-stat, #push-panel .gp-stat { flex: 1; font-size: 12px; color: #93a4c8; }
#guard-panel .gp-stat.ok, #push-panel .gp-stat.ok { color: #34d399; }
#guard-panel .gp-stat.err, #push-panel .gp-stat.err { color: #f87171; }
#guard-panel .gp-btn, #push-panel .gp-btn {
  flex: none; border: 1px solid #3b82f6; color: #93c5fd;
  background: rgba(59, 130, 246, .12);
  border-radius: 8px; padding: 6px 12px; font-size: 12px; cursor: pointer;
}
#guard-panel .gp-btn:active, #push-panel .gp-btn:active { transform: scale(.96); }
#guard-panel .gp-btn.on, #push-panel .gp-btn.on { border-color: #ef4444; color: #fca5a5; background: rgba(239, 68, 68, .12); }
#guard-panel .gp-note, #push-panel .gp-note { margin-top: 12px; font-size: 11px; line-height: 1.7; color: #7d8db1; }
#guard-panel .gp-close, #push-panel .gp-close {
  margin-top: 12px; width: 100%; height: 40px;
  border: none; border-radius: 10px;
  background: rgba(255, 255, 255, .08); color: #c6d2ea; font-size: 14px; cursor: pointer;
}
#guard-panel .gp-close:active, #push-panel .gp-close:active { background: rgba(255, 255, 255, .14); }
#guard-panel .gp-test, #push-panel .gp-test {
  margin-top: 12px; width: 100%; height: 40px;
  border: 1px solid #3b82f6; border-radius: 10px;
  background: rgba(59, 130, 246, .15); color: #93c5fd; font-size: 14px; cursor: pointer;
}
#guard-panel .gp-test:active, #push-panel .gp-test:active { background: rgba(59, 130, 246, .3); }
#push-panel .pp-btn-on { border-color: #10b981; color: #6ee7b7; background: rgba(16, 185, 129, .15); }

/* 通知横幅（bridge.js 创建，替代桌面右下角弹窗） */
#notif-banner {
  position: fixed; z-index: 9999;
  left: 12px; right: 12px; bottom: 16px;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: #fff; border-radius: 14px;
  box-shadow: 0 12px 36px rgba(2, 8, 23, .5);
  padding: 12px 14px;
  transform: translateY(140%);
  transition: transform .35s cubic-bezier(.22, 1, .36, 1);
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
}
#notif-banner.show { transform: translateY(0); }
#notif-banner.nb-register { background: linear-gradient(135deg, #059669, #10b981); }
.nb-head { display: flex; align-items: center; gap: 8px; }
.nb-badge {
  flex: none; font-size: 11px; font-weight: 700; padding: 2px 8px;
  border-radius: 20px; background: rgba(255, 255, 255, .22);
}
.nb-title { flex: 1; font-size: 14px; font-weight: 600; line-height: 1.4; }
.nb-close {
  flex: none; border: none; background: rgba(255, 255, 255, .2); color: #fff;
  width: 24px; height: 24px; border-radius: 50%; font-size: 15px; line-height: 1;
  cursor: pointer;
}
.nb-body { margin-top: 8px; padding-top: 8px; border-top: 1px solid rgba(255, 255, 255, .22); }
.nb-row { display: flex; font-size: 12.5px; line-height: 1.7; }
.nb-k { flex: none; width: 58px; color: rgba(255, 255, 255, .75); }
.nb-v { flex: 1; font-weight: 600; word-break: break-all; }

@media (max-width: 860px) {
  html, body { height: auto; }
  body { overflow: auto !important; -webkit-text-size-adjust: 100%; }

  /* ============================================================
   * iOS 安全区适配（关键）
   * 全屏模式（viewport-fit=cover / 添加到主屏幕）下，
   * 页面内容会延伸到状态栏与底部手势条区域，
   * 必须用 env(safe-area-inset-*) 让开，否则顶部按钮被状态栏盖住点不到。
   * ============================================================ */

  /* ---------- 登录页 ---------- */
  .view-login {
    height: auto; min-height: 100vh; min-height: 100dvh;
    padding: calc(40px + env(safe-area-inset-top)) 0 calc(50px + env(safe-area-inset-bottom));
    overflow-y: auto;
  }
  .login-cards { flex-direction: column; gap: 18px; width: 92%; max-width: 420px; }
  .login-card { width: 100%; padding: 22px 20px 20px; }
  .login-hero .login-title { font-size: 20px; }
  .login-hero .login-sub { margin-bottom: 10px; }
  /* iOS 防自动缩放 */
  .login-input, .cap-input { font-size: 16px; height: 46px; }
  .cap-img { height: 46px; width: 110px; }
  .login-btn { height: 46px; font-size: 16px; }
  .login-foot { margin-top: 14px; line-height: 1.7; padding: 0 20px; }

  /* ---------- 主框架 ---------- */
  .view-main { height: 100vh; height: 100dvh; }
  .topbar {
    /* 顶部让开状态栏，按钮整体下移到安全区下方，保证可点击 */
    height: auto;
    min-height: calc(50px + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) 10px 0;
    gap: 6px;
  }
  .topbar-logo { width: 22px; height: 22px; }
  .topbar-title { font-size: 14px; }
  .backend-switch { margin-left: 6px; gap: 4px; }
  .backend-switch button { padding: 4px 10px; font-size: 11px; }
  .topbar-right { gap: 8px; }
  .conn-status { display: none; }
  .topbar-account { max-width: 90px; font-size: 12px; }
  .btn-ghost { padding: 4px 10px; font-size: 11px; }

  .main-body { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; flex: none;
    border-bottom: 1px solid #252e45;
  }
  .menu {
    display: flex; overflow-x: auto; padding: 0; flex: none;
    -webkit-overflow-scrolling: touch;
  }
  .menu::-webkit-scrollbar { display: none; }
  .menu-item {
    flex: none; padding: 11px 14px; font-size: 13px;
    border-left: none; border-bottom: 2px solid transparent; white-space: nowrap;
  }
  .menu-item.active { border-bottom-color: #93c5fd; }
  .mi-icon { display: none; }
  .sidebar-foot { display: none; }

  /* ---------- 内容区 ---------- */
  .content { padding: 12px 10px calc(62px + env(safe-area-inset-bottom)); overflow-y: auto; }
  .page-head { flex-direction: column; align-items: flex-start; gap: 10px; }
  .page-title h2 { font-size: 18px; }
  .page-tools { width: 100%; }
  .page-tools .btn-primary { flex: 1; text-align: center; }
  .refresh-info { font-size: 11px; }

  /* 筛选条：触屏友好 */
  .filter-bar { gap: 8px; }
  .filter-bar select, .filter-bar input { height: 38px; font-size: 15px; }
  .filter-bar .f-label { font-size: 12px; }
  .range-group, .tab-group { flex-wrap: wrap; }
  .range-group button, .tab-group button { padding: 7px 12px; font-size: 13px; }
  .filter-bar .btn-primary, .filter-bar .btn-plain { flex: 1; min-width: 88px; height: 38px; }

  /* 卡片 */
  .cards { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .cards.mini { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 14px 14px; }
  .stat-card .c-value { font-size: 21px; }
  .stat-card .c-label { font-size: 12px; }
  .stat-card .c-sub { font-size: 10px; }

  /* 表格 */
  .panel { padding: 12px 10px; }
  .panel-head { margin-bottom: 10px; }
  .table-wrap { margin-top: 8px; -webkit-overflow-scrolling: touch; }
  .data-table { font-size: 12px; }
  .data-table th, .data-table td { padding: 8px 10px; }
  .data-table th { top: 0; }

  /* 分页 */
  .pager { flex-wrap: wrap; justify-content: center; padding-top: 12px; }
  .pager button { padding: 7px 16px; font-size: 13px; }

  /* 趋势图 */
  .trend-chart { gap: 8px; height: 200px; }
  .trend-bars { height: 150px; gap: 4px; }
  .trend-bar { width: 16px; }

  /* 我的信息 */
  .info-grid { grid-template-columns: 1fr; gap: 10px; }
  .info-item { flex-direction: column; align-items: flex-start; gap: 2px; }
  .info-item .label { width: auto; text-align: left; margin-right: 0; font-size: 12px; }

  /* 模态框 / 设置 */
  .modal { width: 92%; max-width: 400px; padding: 20px 18px 16px; }
  .settings-body { max-height: 60vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .set-opts { flex-wrap: wrap; }

  /* 加载状态条：随顶栏安全区下移，避免遮挡菜单 */
  .load-status {
    top: calc(58px + env(safe-area-inset-top));
    max-width: 92%; white-space: normal; text-align: center;
  }

  /* 通知横幅：底部让开 iOS 手势条 */
  #notif-banner { bottom: calc(16px + env(safe-area-inset-bottom)); }
}

/* ============================================================
 * v11 UI 打磨：触控反馈 / 过渡动画 / 细节优化（仅移动端）
 * ============================================================ */
@media (max-width: 860px) {
  /* 全局触控反馈：可点元素按下反馈 + 过渡 */
  .menu-item, .range-group button, .tab-group button,
  .btn-primary, .btn-plain, .btn-ghost, .pager button {
    transition: opacity .12s, transform .12s, background-color .12s;
    -webkit-tap-highlight-color: transparent;
  }
  .menu-item:active, .range-group button:active, .tab-group button:active,
  .btn-primary:active, .btn-plain:active, .btn-ghost:active, .pager button:active {
    opacity: .72;
    transform: scale(.97);
  }

  /* 页面切换淡入 */
  .page { animation: pageFade .22s ease-out; }
  @keyframes pageFade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

  /* 表格行点击反馈 */
  .data-table tbody tr { transition: background-color .15s; }
  .data-table tbody tr:active { background: rgba(59, 130, 246, .08); }

  /* 数字等宽渲染，金额对齐更清晰 */
  .c-value { font-variant-numeric: tabular-nums; }

  /* 隐藏菜单/表格横向滚动条，滚动更干净 */
  .menu::-webkit-scrollbar, .table-wrap::-webkit-scrollbar { height: 0; }

  /* 加载状态条淡入 */
  .load-status:not(.hidden) { animation: pageFade .2s ease-out; }

  /* 模态框/设置弹窗上滑入场 */
  .modal { animation: modalUp .24s cubic-bezier(.22, 1, .36, 1); }
  @keyframes modalUp { from { opacity: 0; transform: translateY(24px) scale(.97); } to { opacity: 1; transform: none; } }
  .modal-mask:not(.hidden) { animation: maskIn .18s ease-out; }
  @keyframes maskIn { from { opacity: 0; } to { opacity: 1; } }
}

.trend-warn{font-size:12px;color:#8a8f98;background:rgba(255,255,255,.06);border:1px solid rgba(255,255,255,.08);border-radius:8px;padding:6px 10px;margin-bottom:8px;line-height:1.5}
