/* ======================= 手机 / 窄屏（宽度 < 1000px）=======================
 * 关闭整屏等比缩放，改为单列流式布局：卡片两列、面板纵向排列、地图与图表给定高度、表格横向滚动、弹层全屏。
 */
@media (max-width: 999px) {
  html, body { overflow-x: hidden; -webkit-text-size-adjust: 100%; }
  body.fit { overflow: auto; height: auto; }
  .dashboard, .dashboard.fit { width: auto; max-width: 100%; transform: none !important; margin: 0 !important; padding: 10px 10px 16px; }

  /* 顶栏：标题居上，操作区换行 */
  .header { height: auto; display: flex; flex-direction: column; align-items: stretch; gap: 8px; padding-bottom: 10px; margin-bottom: 8px; }
  .header:after { display: none; }
  .brand { display: none; }
  .title { order: 0; } .title h1 { font-size: 20px; letter-spacing: .04em; } .title small { font-size: 9px; letter-spacing: .16em; }
  .head-right { order: 1; justify-self: auto; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px; text-align: left; }
  .head-right #date { order: 3; font-size: 11px; }
  .head-right .status { order: 4; font-size: 11px; }
  .head-right .theme-btn { order: 2; }
  .board[data-board="overview"] .grid-ov { height: auto !important; }
  .range { order: 1; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .range::-webkit-scrollbar { display: none; }
  #range-presets { display: flex; gap: 2px; white-space: nowrap; }
  .range button { height: 28px; padding: 0 11px; font-size: 12px; flex: none; }
  .range .menu { position: fixed; left: 10px; right: 10px; top: 120px; width: auto; max-height: 60vh; grid-template-columns: repeat(3, 1fr); }
  .range .custom { flex-wrap: wrap; }

  /* 看板切换：横向滑动 */
  .boards { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; gap: 4px; position: sticky; top: 0; z-index: 30; }
  .boards::-webkit-scrollbar { display: none; }
  .boards button { flex: none; height: 34px; padding: 0 14px; font-size: 13px; white-space: nowrap; }

  /* 指标卡：两列 */
  .cards, .mcards { grid-template-columns: 1fr 1fr !important; gap: 8px; }
  .card, .mcard { padding: 10px 12px; }
  .card .value, .mcard .value { font-size: 24px; }
  .card .sub, .mcard .sub { white-space: normal; }

  /* 所有看板网格改为单列，取消固定高度 */
  .grid-ov, .grid-m, .grid-mb, .grid-ops, .grid-co, .grid-dz, .grid-al, .focus, .modules, .qc-groups, .qc-trends, .rankings, .capacity, .bottom-grid { grid-template-columns: 1fr !important; grid-template-rows: none !important; height: auto !important; min-height: 0 !important; }
  .grid-mb.swap > .panel:first-child { order: 0; } .grid-mb.swap > .panel:last-child { order: 0; }
  .mcol, .mcol:last-child, .mcol.single { display: flex; flex-direction: column; gap: 10px; }
  .grid-ov > .panel, .mcol .panel, .grid-dz > .panel, .grid-al > .panel { min-height: 0; overflow: visible; }
  .grid-m, .grid-ov, .grid-co, .grid-dz, .grid-al, .grid-ops, .focus { gap: 10px; margin-bottom: 10px; }

  .grid-ov > *, .grid-m > *, .grid-mb > *, .grid-ops > *, .grid-co > *, .grid-dz > *, .grid-al > *, .mcol > *, .focus > *, .qc-groups > *, .qc-trends > * { min-width: 0; max-width: 100%; }
  .phead > span { max-width: 58%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
  .phead h3 { font-size: 14px; white-space: nowrap; }
  .mapbox .phead > span, .mheat .phead > span { max-width: 50%; }

  /* 地图：固定高度 */
  .mapbox, .mheat { position: relative; height: 380px; min-height: 380px; }
  .board[data-board="overview"] .mapbox { height: 420px; }
  .mheat { height: 420px; }
  .map-hint { display: none; }
  .growth { height: auto; grid-template-columns: 1fr 1fr 1fr; gap: 4px; padding: 8px 10px; }
  .growth div { padding: 0 6px; } .growth b { font-size: 15px; } .growth small { font-size: 9px; }
  .mheat .map-area { inset: 40px 0 64px; }

  /* 图表与面板高度 */
  .chart.tall { height: 260px; }
  .chart.fill { position: relative; inset: auto; height: 340px; }
  .grid-co .panel, .grid-dz > .panel { height: auto; }
  .grid-co > .panel { height: 400px; } .grid-co > .panel .chart.fill { position: absolute; inset: 40px 0 0; height: auto; }
  .grid-dz > .panel:nth-child(2) { height: 360px; } .grid-dz > .panel:nth-child(2) .chart.fill { position: absolute; inset: 40px 0 0; height: auto; }
  [id$="-pie"] { height: 220px !important; }
  [id$="-trend"] { height: 210px !important; }
  .extra { max-height: none; }
  .core-table { overflow-x: auto; } .core-table table { min-width: 340px; }
  .board[data-board="overview"] .core-table td { padding: 10px 4px; } .board[data-board="overview"] .core-table .v { font-size: 16px; }
  .flow { flex-wrap: wrap; justify-content: center; gap: 10px 4px; } .flow .arrow { display: none; } .flow .step { flex: 0 0 30%; }
  .module .stats { grid-template-columns: 1fr 1fr; }
  .fcard { grid-template-columns: 1fr 1fr; } .fcard > div:last-child { grid-column: 1 / -1; }
  .qc { grid-template-columns: 60px 1fr; } .qc .ring { width: 58px; height: 58px; }
  .al-row small { max-width: 60vw; } .al-summary { grid-template-rows: none; }
  .rank .row, .toplist .row { font-size: 12px; }
  .mcol.single .toplist .row { margin-bottom: 6px; }

  /* 实时动态：单列，业务切换横滑 */
  .feed-panel .phead { height: auto; flex-wrap: wrap; gap: 6px; padding: 8px 12px; }
  .feed-tabs { width: 100%; overflow-x: auto; scrollbar-width: none; flex-wrap: nowrap; } .feed-tabs::-webkit-scrollbar { display: none; }
  .feed-tabs button { flex: none; height: 26px; } .feed-tabs .feed-time { display: none; }
  .feed { grid-template-columns: 1fr !important; }
  .feed-row { font-size: 12px; grid-template-columns: auto 1fr; } .feed-row span { grid-column: 2; font-size: 11px; opacity: .8; }
  .footer { flex-direction: column; gap: 4px; text-align: center; }

  /* 明细弹层：全屏 */
  .drill { align-items: stretch; }
  .drill-card { width: 100vw; max-width: 100vw; height: 100%; max-height: 100%; border-radius: 0 !important; }
  .drill-head { flex-wrap: wrap; gap: 8px; padding: 12px 52px 10px 14px; position: relative; } .drill-head h2 { font-size: 15px; } .drill-close { position: absolute; right: 10px; top: 10px; } .drill-head span { flex-basis: 100%; order: 3; }
  .drill-body { padding: 12px 12px 24px; -webkit-overflow-scrolling: touch; }
  .drill-stats { flex-wrap: wrap; } .drill-stats div { flex: 1 1 40%; }
  .drill-tbl { min-width: 720px; } .drill-body { overflow-x: auto; }
  .drill-filter input, .drill-filter select { flex: 1 1 45%; min-width: 0; max-width: none; } .drill-filter button { flex: 1 1 40%; }
  .timeline { overflow-x: auto; } .timeline div { min-width: 92px; }
  .detail-groups { grid-template-columns: 1fr; }
  .week-nav { flex-wrap: wrap; } table.week { min-width: 640px; }
  .gate-card { width: calc(100vw - 32px); padding: 26px 20px; }
}

/* 横屏手机：卡片三列 */
@media (max-width: 999px) and (orientation: landscape) {
  .cards, .mcards { grid-template-columns: repeat(3, 1fr) !important; }
}
