/* ═══════════════════════════════════════════════════
   mobile.css — 移动端专属交互界面
   仅当 <html class="is-mobile"> 时生效（由 js/device.js 设置）
   全部颜色走 CSS 变量（与桌面 4 主题联动）
   ═══════════════════════════════════════════════════ */

/* ───────── 双视图显隐 ───────── */
html.is-mobile #desktopView { display: none !important; }
html:not(.is-mobile) #mobileView { display: none !important; }
html.is-mobile #mobileView { display: flex !important; flex-direction: column; min-height: 100dvh; }

/* ───────── 移动端基础 ───────── */
html.is-mobile body { font-size: 15px; }
html.is-mobile #mobileView { display: flex; flex-direction: column; min-height: 100dvh; }

/* ───────── 移动端顶部栏 ───────── */
html.is-mobile .mv-topbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 14px calc(10px + env(safe-area-inset-top, 0px));
  display: flex; flex-direction: column; gap: 8px;
}
html.is-mobile .mv-brand { display: flex; align-items: center; justify-content: space-between; }
html.is-mobile .mv-brand h1 { font-size: 17px; font-weight: 800; }
html.is-mobile .mv-live { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); }
html.is-mobile .mv-actions { display: flex; gap: 8px; align-items: center; }
html.is-mobile .mv-search-wrap { position: relative; flex: 1; }
html.is-mobile #mvGlobalSearch {
  width: 100%; height: 40px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text);
  border-radius: 20px; padding: 0 16px; font-size: 14px; outline: none;
}
html.is-mobile #mvGlobalSearch:focus { border-color: var(--brand); }
html.is-mobile #mvSearchClear { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); }
html.is-mobile .mv-search-results {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 60;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-lg); max-height: 60vh; overflow-y: auto;
}
html.is-mobile .mv-search-results .sr-item {
  display: block; width: 100%; text-align: left; border: none; background: none;
  padding: 12px 14px; border-bottom: 1px solid var(--border); cursor: pointer; color: var(--text);
}
html.is-mobile .mv-search-results .sr-item:last-child { border-bottom: none; }
html.is-mobile .mv-search-results .sr-id { font-size: 11px; color: var(--text-3); }
html.is-mobile .mv-search-results .sr-name { font-size: 14px; margin-top: 2px; line-height: 1.45; word-break: break-word; }
html.is-mobile .mv-search-results .sr-meta { font-size: 11px; color: var(--text-3); margin-top: 3px; }
html.is-mobile .mv-search-results .sr-empty { padding: 16px; text-align: center; color: var(--text-3); font-size: 13px; }

/* ───────── 移动端内容区 ───────── */
html.is-mobile .mv-content {
  flex: 1;
  padding: 14px 14px calc(76px + env(safe-area-inset-bottom, 0px)); /* 底部留白防 tabbar 遮挡 */
}
html.is-mobile .mv-view { display: none; }
html.is-mobile .mv-view.active { display: block; animation: fadeIn .25s ease-out; }

/* ───────── 移动端 KPI 2×2 ───────── */
html.is-mobile .mv-kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
html.is-mobile .mv-kpi-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 14px 16px;
}
html.is-mobile .mv-kpi-card .label { font-size: 12px; color: var(--text-2); }
html.is-mobile .mv-kpi-card .value { font-size: 24px; font-weight: 800; margin: 4px 0 2px; letter-spacing: -0.5px; }
html.is-mobile .mv-kpi-card .sub { font-size: 11px; color: var(--text-3); }
html.is-mobile .mv-kpi-minibar { height: 4px; border-radius: 2px; background: var(--bg-soft); margin-top: 6px; overflow: hidden; }
html.is-mobile .mv-kpi-minibar i { display: block; height: 100%; border-radius: 2px; }

/* ───────── 移动端分组标题 ───────── */
html.is-mobile .mv-section-title {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 15px; font-weight: 700; margin: 18px 0 10px;
}
html.is-mobile .mv-section-title .mv-count { font-size: 11px; font-weight: 500; color: var(--text-3); background: var(--bg-soft); padding: 2px 10px; border-radius: 12px; }

/* ───────── 移动端小组卡 ───────── */
html.is-mobile .mv-group-card {
  border: 1px solid var(--border); border-radius: 14px; background: var(--surface);
  padding: 14px; margin-bottom: 12px;
}
html.is-mobile .mv-group-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
html.is-mobile .mv-group-name { font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 6px; }
html.is-mobile .mv-group-avg { font-size: 16px; font-weight: 800; }

/* ───────── 移动端目标卡 ───────── */
html.is-mobile .mv-goal-card {
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2);
  padding: 12px; margin-bottom: 8px;
}
html.is-mobile .mv-goal-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
html.is-mobile .mv-goal-name { font-weight: 600; font-size: 13px; }
html.is-mobile .mv-goal-rate { font-weight: 800; font-size: 15px; }
html.is-mobile .mv-goal-meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-2); margin-bottom: 8px; flex-wrap: wrap; gap: 4px; }
html.is-mobile .mv-goal-actions { display: flex; gap: 8px; flex-wrap: wrap; }
html.is-mobile .mv-goal-actions .btn { min-height: 36px; font-size: 12px; }

/* ───────── 移动端里程碑 tab ───────── */
html.is-mobile .mv-ms-tabs {
  display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 10px; -webkit-overflow-scrolling: touch;
}
html.is-mobile .mv-ms-tab {
  border: none; background: var(--bg-soft); color: var(--text-2);
  padding: 8px 16px; border-radius: 20px; font-size: 13px; white-space: nowrap; cursor: pointer;
  min-height: 36px;
}
html.is-mobile .mv-ms-tab.active { background: var(--brand); color: #fff; font-weight: 600; }

/* ───────── 移动端卡片列表 ───────── */
html.is-mobile .mv-card-list { display: flex; flex-direction: column; gap: 10px; }
html.is-mobile .mv-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 14px; cursor: pointer; transition: border-color .15s;
}
html.is-mobile .mv-card:active { border-color: var(--brand); transform: scale(0.99); }
html.is-mobile .mv-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
html.is-mobile .mv-card-id { font-size: 11px; color: var(--text-3); }
html.is-mobile .mv-card-title { font-size: 14px; font-weight: 600; margin: 6px 0 8px; line-height: 1.5; word-break: break-word; }
html.is-mobile .mv-card-meta { display: flex; flex-wrap: wrap; gap: 8px; font-size: 12px; color: var(--text-2); }
html.is-mobile .mv-card-meta span { display: inline-flex; align-items: center; gap: 4px; }

/* 里程碑卡内的阻塞警示 */
html.is-mobile .mv-blocker-alert {
  margin-top: 8px; font-size: 12px; color: var(--red); background: rgba(245,34,45,0.08);
  border-radius: 6px; padding: 5px 8px; display: inline-flex; align-items: center; gap: 4px;
}

/* ───────── 移动端 mini KPI（阻塞/任务 tab 顶部） ───────── */
html.is-mobile .mv-mini-kpi { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
html.is-mobile .mv-mini-kpi .mv-kpi-card { padding: 10px 8px; text-align: center; border-radius: 12px; }
html.is-mobile .mv-mini-kpi .label { font-size: 10px; }
html.is-mobile .mv-mini-kpi .value { font-size: 18px; }

/* ───────── 移动端底部 Tab 导航 ───────── */
html.is-mobile .mv-tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 100;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex; justify-content: space-around;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-shadow: 0 -4px 20px rgba(15,23,42,0.06);
}
html.is-mobile .mv-tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; min-height: 56px; border: none; background: none; cursor: pointer;
  color: var(--text-3); font-size: 10px;
}
html.is-mobile .mv-tab svg { transition: transform .15s; }
html.is-mobile .mv-tab.active { color: var(--brand); font-weight: 600; }
html.is-mobile .mv-tab.active svg { transform: translateY(-1px); }

/* ───────── 移动端抽屉全屏化 ───────── */
html.is-mobile .drawer {
  width: 100% !important; max-width: none !important;
  height: 100dvh !important; border-radius: 0 !important;
  animation: mvSlideIn .3s cubic-bezier(0.2, 0, 0, 1);
}
html.is-mobile .drawer-head { padding: calc(14px + env(safe-area-inset-top, 0px)) 16px 14px; }
html.is-mobile .drawer-body { padding: 16px calc(16px) calc(40px + env(safe-area-inset-bottom, 0px)); }
html.is-mobile .drawer-back, html.is-mobile .drawer-close { min-width: 44px; min-height: 44px; }
@keyframes mvSlideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }

/* ───────── 移动端浮层全屏化 ───────── */
html.is-mobile .modal { width: 100vw !important; max-width: none !important; max-height: 100dvh !important; border-radius: 16px 16px 0 0; align-self: flex-end; }
html.is-mobile .modal-root { align-items: flex-end; }

/* ───────── 移动端月度明细（优化显示大小） ───────── */
html.is-mobile .modal-body { padding: 12px 12px calc(30px + env(safe-area-inset-bottom, 0px)); }
html.is-mobile .modal-body .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
html.is-mobile .modal-body .data-table { min-width: 0 !important; font-size: 12px; }
html.is-mobile .modal-body .data-table th,
html.is-mobile .modal-body .data-table td { padding: 7px 8px; white-space: nowrap; }
html.is-mobile .modal-body .data-table td:nth-child(4) { min-width: 88px !important; }
html.is-mobile .modal-body .data-table td:nth-child(5) { white-space: normal !important; max-width: 130px; line-height: 1.4; }
html.is-mobile .month-ms-btn { font-size: 10px; padding: 2px 7px; }
html.is-mobile .modal-body .progress { height: 4px; margin: 2px 0 4px; }
html.is-mobile .modal-head { padding: calc(14px + env(safe-area-inset-top, 0px)) 14px 12px; }
html.is-mobile .modal-head h3 { font-size: 15px; }

/* ───────── 移动端详情字段 ───────── */
html.is-mobile .detail-field { grid-template-columns: 88px 1fr; font-size: 13px; }
html.is-mobile .detail-desc { font-size: 13px; line-height: 1.8; }

/* ───────── 移动端空态 ───────── */
html.is-mobile .empty-state { padding: 40px 0; font-size: 14px; }

/* ───────── 移动端加载动画适配 ───────── */
html.is-mobile .loading-overlay { z-index: 300; }
