/*!
 * STATWISE mobile / tablet layout — ONLY when html has .sw-mobile
 * Desktop (.sw-pc) is completely unaffected.
 */

/* ========== Tablet (<1024 or UA mobile mid size) ========== */
html.sw-mobile body {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  touch-action: manipulation;
}

/* ---------- HOME (index) ---------- */
html.sw-mobile .utility {
  height: auto;
  min-height: 48px;
  padding: 8px 12px;
  gap: 8px;
  flex-wrap: wrap;
}
html.sw-mobile .utility-brand { font-size: 16px; }
html.sw-mobile .utility-brand .brand-icon { width: 28px; height: 28px; }
html.sw-mobile .utility-meta { display: none; }
html.sw-mobile .utility-right { width: 100%; justify-content: flex-end; }
html.sw-mobile .lang-switch { height: 36px; padding: 0 10px 0 6px; }
html.sw-mobile .lang-switch .lang-icon { width: 22px; height: 22px; }
html.sw-mobile .lang-switch .seg b { min-width: 32px; padding: 5px 8px; font-size: 12px; }

html.sw-mobile .nav {
  height: auto;
  min-height: 44px;
  padding: 6px 10px;
  flex-wrap: wrap;
  gap: 6px;
}
html.sw-mobile .nav-links {
  width: 100%;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 4px 10px;
  order: 2;
}
html.sw-mobile .nav-links button {
  font-size: 11px;
  padding: 10px 4px;
  min-height: 40px;
}
html.sw-mobile .nav-login {
  order: 1;
  margin-left: auto;
  min-height: 40px;
  padding: 8px 4px;
}

html.sw-mobile .stage { padding: 20px 12px 28px; }
html.sw-mobile .hero-copy h1 { font-size: 34px; }
html.sw-mobile .card,
html.sw-mobile .module-panel {
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
}
html.sw-mobile .card-body { padding: 18px 14px 20px; }
html.sw-mobile .field input {
  height: 44px;
  font-size: 16px; /* 避免 iOS 自动放大 */
}
html.sw-mobile .btn,
html.sw-mobile .btn-secondary {
  min-height: 44px;
  padding: 12px 16px;
  font-size: 14px;
}
html.sw-mobile .cta-bar {
  font-size: 12px;
  gap: 8px 12px;
  padding: 12px 10px;
  flex-direction: column;
  text-align: center;
}
html.sw-mobile .cta-bar span { display: none; }
html.sw-mobile .footer-tagline { font-size: 13px; }

/* ---------- Phone refinements ---------- */
html.sw-phone .hero-copy h1 { font-size: 30px; }
html.sw-phone .nav-links button { letter-spacing: 0.02em; }

/* ========== EQA workbench ========== */
html.sw-mobile,
html.sw-mobile body {
  overflow: auto;
  min-height: 100%;
  height: auto;
}

html.sw-mobile .utility {
  height: auto;
  min-height: 40px;
  padding: 6px 10px;
  position: sticky;
  top: 0;
  z-index: 20;
}
html.sw-mobile .topbar {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding: 10px;
  position: sticky;
  top: 40px;
  z-index: 19;
}
html.sw-mobile .topbar h1 { font-size: 13px; }
html.sw-mobile .topbar .sub { font-size: 10px; }
html.sw-mobile .userbox {
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-start;
}
html.sw-mobile .start-btn,
html.sw-mobile .ghost {
  min-height: 42px;
  padding: 10px 14px;
  font-size: 13px;
}
html.sw-mobile .lang-switch { height: 34px; }

/* 横向布局 → 上下堆叠 */
html.sw-mobile .layout {
  display: flex;
  flex-direction: column;
  height: auto;
  max-height: none;
  min-height: 0;
  overflow: visible;
  padding: 8px;
  gap: 8px;
}
html.sw-mobile .filters {
  max-height: none;
  overflow: visible;
  padding: 10px;
}
html.sw-mobile .filters h2 { font-size: 14px; margin-bottom: 8px; }
html.sw-mobile .row2 {
  grid-template-columns: 1fr;
  gap: 8px;
}
html.sw-mobile .field { margin-bottom: 10px; }
html.sw-mobile .field label { font-size: 12px; margin-bottom: 4px; }
html.sw-mobile .field select,
html.sw-mobile .field input:not([type="checkbox"]),
html.sw-mobile .field textarea {
  min-height: 42px;
  height: auto;
  font-size: 16px;
  padding: 10px 12px;
}

/* 切片器：纵向堆叠工具与列表 */
html.sw-mobile .slicer-tabs {
  flex-direction: column;
  gap: 6px;
}
html.sw-mobile .slicer-tabs button,
html.sw-mobile .subtabs button,
html.sw-mobile .tabs button,
html.sw-mobile .exports button,
html.sw-mobile .toolbar button,
html.sw-mobile .slicer-tools button {
  min-height: 42px;
  padding: 10px 12px;
  font-size: 13px;
  width: 100%;
  text-align: center;
}
html.sw-mobile .slicer-tools {
  flex-direction: column;
  gap: 6px;
}
html.sw-mobile .slicer-list {
  max-height: 220px;
  font-size: 14px;
}
html.sw-mobile .slicer-list label {
  padding: 8px 4px;
  gap: 10px;
  min-height: 40px;
  align-items: center;
}
html.sw-mobile .slicer-list input[type="checkbox"] {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

html.sw-mobile .main {
  max-height: none;
  overflow: visible;
  min-height: 50vh;
}
html.sw-mobile .tabs {
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px;
}
html.sw-mobile .tabs button { flex: 1 1 calc(50% - 6px); }
html.sw-mobile .kpi {
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 8px;
}
html.sw-mobile .kpi .cell {
  padding: 8px 10px;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}
html.sw-mobile .kpi .cell em { font-size: 11px; }
html.sw-mobile .kpi .cell b { font-size: 16px; }

html.sw-mobile .subtabs,
html.sw-mobile .toolbar {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding: 8px;
}
html.sw-mobile .exports {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
}
html.sw-mobile .exports button { width: 100%; }

/* 图表满宽自适应 */
html.sw-mobile .chart,
html.sw-mobile canvas,
html.sw-mobile svg.chart,
html.sw-mobile .echarts,
html.sw-mobile [class*="chart"] {
  width: 100% !important;
  max-width: 100% !important;
  height: auto !important;
}

/* 表格：恢复内容宽度 + 横向滚动（手机可左右滑） */
html.sw-mobile .table-wrap {
  overflow-x: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  max-height: 60vh;
  border: 1px solid var(--line, #d5dde6);
}
html.sw-mobile table {
  width: max-content;
  min-width: 100%;
  table-layout: auto;
  font-size: 12px;
}
html.sw-mobile th,
html.sw-mobile td {
  white-space: nowrap;
  overflow: visible;
  text-overflow: clip;
  padding: 8px 10px;
  word-break: normal;
  overflow-wrap: normal;
}
html.sw-mobile .status { font-size: 10px; padding: 6px 8px; }

html.sw-mobile .drawer {
  position: fixed;
  inset: 0;
  width: 100%;
  max-width: 100%;
  z-index: 40;
}
html.sw-mobile .drawer-actions button {
  min-height: 44px;
  font-size: 14px;
}
html.sw-mobile .note-card button {
  min-height: 36px;
  padding: 6px 12px;
  font-size: 12px;
}

/* Phone: denser */
html.sw-phone .kpi { grid-template-columns: 1fr 1fr; }
html.sw-phone .exports { grid-template-columns: 1fr; }
html.sw-phone .tabs button { flex: 1 1 100%; }
html.sw-phone .table-wrap { max-height: 55vh; }

/* Module placeholders */
html.sw-mobile .wrap { margin: 24px auto; padding: 0 12px; }
html.sw-mobile .wrap .card { padding: 20px 16px; }
html.sw-mobile .wrap h1 { font-size: 22px; }
html.sw-mobile .wrap .nav {
  gap: 10px;
  padding: 8px 12px;
  height: auto;
  flex-wrap: wrap;
}
html.sw-mobile .wrap .nav a {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
}
