/* ===== H5 V5 移动端适配层 ===== */
/* 只在窄屏生效，桌面端完全不受影响 */

@media (max-width: 991.98px) {

  /* ---------- 基础 ---------- */
  html, body {
    overflow-x: hidden !important;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior-y: contain;
  }
  body { max-width: 100vw; }
  .ant-btn { white-space: nowrap !important; }
  .ant-btn-sm { padding-inline: 8px !important; font-size: 12px !important; }
  .ant-btn > span { white-space: nowrap !important; }
  input, textarea, select { font-size: 16px !important; }  /* 防 iOS 聚焦放大 */

  /* ---------- 顶部栏 ---------- */
  header.ant-layout-header {
    height: auto !important;
    min-height: 48px !important;
    line-height: 1.3 !important;
    padding: 8px 10px !important;
    display: flex !important;
    align-items: center !important;
    flex-wrap: nowrap !important;
    gap: 8px !important;
    position: sticky;
    top: 0;
    z-index: 900;
  }
  /* 汉堡按钮隐藏（改用底部导航） */
  header.ant-layout-header > div:first-child > button,
  header.ant-layout-header > div:first-child > .ant-btn { display: none !important; }
  header.ant-layout-header > div:first-child {
    flex: 0 1 auto !important;
    min-width: 0 !important;
    overflow: hidden;
  }
  header.ant-layout-header > div:first-child > div {
    font-size: 13px !important;
    font-weight: 600 !important;
    border-left: none !important;
    padding-left: 2px !important;
    margin-left: 0 !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 34vw;
  }
  /* 中间的跑马灯区隐藏 */
  header.ant-layout-header > div:nth-child(2) { display: none !important; }
  /* 右侧集群 */
  header.ant-layout-header > div:last-child {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    gap: 6px !important;
    flex-wrap: nowrap !important;
    justify-content: flex-end !important;
    margin-left: auto;
  }
  header.ant-layout-header > div:last-child > div { gap: 6px !important; flex-shrink: 0 !important; margin-right: 0 !important; }
  header.ant-layout-header .ant-select { width: auto !important; min-width: 62px !important; }
  header.ant-layout-header .ant-select .ant-select-selector { padding-inline: 6px !important; }
  header.ant-layout-header .ant-select-selection-item,
  header.ant-layout-header .ant-select-selection-search-input { font-size: 12px !important; }
  /* 原始时钟文本：手机上隐藏，换成自定义的小时钟 */
  header .h5-native-clock { display: none !important; }
  header > div:last-child > button { display: none !important; }
  header .ant-avatar { width: 28px !important; height: 28px !important; line-height: 28px !important; }
  header .ant-dropdown-trigger { width: 28px !important; min-width: 28px !important; }
  .h5-clock {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 11px;
    color: #94a3b8;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    flex-shrink: 0;
  }
  /* 在线设备计数 */
  header .h5-online {
    display: inline-flex !important;
    align-items: center;
    gap: 3px;
    padding: 2px 5px !important;
    font-size: 10.5px !important;
    white-space: nowrap !important;
    flex-shrink: 0;
    padding: 3px 7px !important;
    border-radius: 999px !important;
    background: rgba(255, 77, 79, .12) !important;
    transform: scale(1) !important;
  }
  header .h5-online * { font-size: 10.5px !important; }
  header .h5-online .ant-badge { transform: scale(.88); transform-origin: center; }

  /* ---------- 主体 ---------- */
  main.ant-layout-content { overflow-x: hidden; }
  main.ant-layout-content > div {
    padding: 8px 8px calc(74px + env(safe-area-inset-bottom)) !important;
    min-height: 0 !important;
    overflow: visible !important;
  }

  /* ---------- 卡片 ---------- */
  .ant-card { width: 100% !important; max-width: 100% !important; }
  .ant-card-body { padding: 0 !important; }
  .h5card { border-radius: 12px !important; }
  .h5grid {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 10px !important;
  }
  .h5grid > * { width: 100% !important; flex: 0 0 100% !important; min-width: 0 !important; }


  /* 虚拟列表：每行宽度与卡片整宽 */
  .h5grid { width: 100% !important; flex: 1 1 100% !important; min-width: 0 !important; }
  .h5grid .ant-card { width: 100% !important; }
  .h5grid .ant-card-body { width: 100% !important; }

  /* 设备卡片内部 */
  .h5flex { gap: 8px !important; padding: 8px !important; }
  .h5kv { padding: 4px 0 !important; }
  .h5k {
    width: 62px !important;
    min-width: 62px !important;
    font-size: 11.5px !important;
    padding-right: 4px !important;
  }
  .h5v { font-size: 12px !important; word-break: break-all; }
  .h5kv input { font-size: 13px !important; padding: 2px 6px !important; }

  /* 卡片顶部工具条按钮压紧 */
  .h5chead { padding: 6px 8px !important; gap: 6px !important; flex-wrap: nowrap !important; }
  .h5chead .ant-btn { padding: 0 7px !important; height: 26px !important; font-size: 12px !important; }
  .h5chead .ant-btn-icon-only { width: 26px !important; height: 26px !important; padding: 0 !important; }

  /* ---------- 筛选栏 ---------- */
  .h5filters { gap: 8px !important; flex-wrap: wrap !important; row-gap: 8px !important; }
  .h5filters .ant-space { flex-wrap: wrap !important; row-gap: 6px !important; }
  .h5filters .ant-btn { min-width: 0 !important; padding-inline: 9px !important; }
  .h5filters .ant-divider { display: none !important; }
  .h5filters .h5adv { display: none !important; width: 100% !important; }
  .h5filters.h5open .h5adv { display: flex !important; flex-direction: column; gap: 8px; }
  .h5filters.h5open .h5adv > div {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    width: 100% !important;
  }
  .h5filters .h5adv .ant-form-item,
  .h5filters .h5adv .ant-picker,
  .h5filters .h5adv .ant-select { width: calc(50vw - 30px) !important; max-width: 200px !important; }
  .h5filters .h5adv .ant-form-item { margin: 0 !important; }
  .h5filters .h5adv .ant-picker-range { width: 100% !important; }
  .h5filter-toggle {
    display: flex; align-items: center; justify-content: center; gap: 4px;
    order: 99; flex: 1 1 100%;
    height: 32px; padding: 0 10px; border-radius: 8px;
    border: 1px dashed #cbd5e1; background: #f8fafc; color: #475569;
    font-size: 12.5px; line-height: 1; margin-top: 2px;
  }
  .h5filter-toggle.on { background: #2db368; border-color: #2db368; color: #fff; }

  /* ---------- 表格 ---------- */
  .ant-table-wrapper { width: 100% !important; max-width: 100% !important; }
  .ant-table { font-size: 12px !important; }
  .ant-table-content, .ant-table-body {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    max-width: 100% !important;
  }
  .ant-table-content > table, .ant-table-body > table { min-width: 100% !important; width: max-content !important; }
  .ant-table-thead > tr > th, .ant-table-tbody > tr > td { padding: 8px 8px !important; font-size: 12px !important; white-space: nowrap; }
  .ant-table-cell-ellipsis { max-width: 150px !important; }
  .ant-table-placeholder > td { white-space: normal !important; }


  /* 表格改卡片式 */
  .h5tblwrap .ant-table-content, .h5tblwrap .ant-table-body { overflow-x: visible !important; }
  table.h5tbl { display: block !important; width: 100% !important; min-width: 0 !important; }
  table.h5tbl colgroup { display: none !important; }
  table.h5tbl thead { display: none !important; }
  table.h5tbl tbody { display: block !important; width: 100% !important; }
  table.h5tbl tbody > tr {
    display: block !important;
    background: #fff;
    border: 1px solid #eef1f5;
    border-radius: 10px;
    margin: 0 0 8px;
    padding: 4px 10px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .03);
  }
  table.h5tbl tbody > tr > td {
    display: flex !important;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    width: auto !important;
    max-width: none !important;
    border: 0 !important;
    padding: 5px 0 !important;
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
    font-size: 12px !important;
    text-align: right;
  }
  table.h5tbl tbody > tr > td + td { border-top: 1px dashed #f2f4f7 !important; }
  table.h5tbl tbody > tr > td::before {
    content: attr(data-label);
    color: #8c8c8c;
    font-size: 11.5px;
    font-weight: 400;
    flex: 0 0 auto;
    text-align: left;
    padding-top: 1px;
  }
  table.h5tbl tbody > tr > td.h5td-nolabel { justify-content: flex-end; }
  table.h5tbl tbody > tr > td.h5td-nolabel::before { content: ''; display: none; }
  /* 空状态 / 展开行保持原样 */
  table.h5tbl tbody > tr.ant-table-placeholder { display: block !important; padding: 0 !important; }
  table.h5tbl tbody > tr.ant-table-placeholder > td { display: block !important; text-align: center; }
  table.h5tbl tbody > tr.ant-table-placeholder > td::before { display: none !important; }
  table.h5tbl tbody > tr.ant-table-expanded-row > td { display: block !important; }

  /* 分页 */
  .ant-pagination { display: flex !important; flex-wrap: wrap; justify-content: center; gap: 4px; row-gap: 6px; }
  .ant-pagination-total-text { font-size: 12px; }
  .ant-pagination .ant-pagination-item,
  .ant-pagination .ant-pagination-prev,
  .ant-pagination .ant-pagination-next { min-width: 28px !important; height: 28px !important; line-height: 26px !important; }

  /* ---------- 弹窗 / 抽屉 ---------- */
  .ant-modal { width: 100vw !important; max-width: 100vw !important; top: 0 !important; margin: 0 !important; padding: 0 !important; }
  .ant-modal .ant-modal-content {
    border-radius: 0 !important;
    min-height: 100dvh;
    max-height: 100dvh;
    display: flex;
    flex-direction: column;
    padding: 0 !important;
  }
  .ant-modal .ant-modal-header { padding: 12px 14px !important; margin: 0 !important; border-bottom: 1px solid #f0f0f0; flex: 0 0 auto; }
  .ant-modal .ant-modal-title { font-size: 15px !important; }
  .ant-modal .ant-modal-close { top: 8px !important; inset-inline-end: 8px !important; }
  .ant-modal .ant-modal-body {
    padding: 12px 14px !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    flex: 1 1 auto;
    min-height: 0;
  }
  .ant-modal .ant-modal-footer { padding: 10px 14px calc(10px + env(safe-area-inset-bottom)) !important; margin: 0 !important; border-top: 1px solid #f0f0f0; flex: 0 0 auto; }
  .ant-drawer .ant-drawer-content-wrapper { width: 100vw !important; max-width: 100vw !important; }

  /* 弹窗里的表单竖排 */
  .ant-modal .ant-form-item { margin-bottom: 12px !important; }
  .ant-modal .ant-form-item-label { padding-bottom: 2px !important; }
  .ant-modal .ant-form-item-label > label { font-size: 12.5px !important; height: auto !important; }
  .ant-modal .ant-form-item-control { min-width: 0 !important; }
  .ant-modal .ant-row { row-gap: 0; }
  .ant-modal .ant-col { flex: 0 0 100% !important; max-width: 100% !important; }

  /* ---------- 顶部右上角通知 ---------- */
  .ant-notification { max-width: calc(100vw - 16px) !important; width: calc(100vw - 16px) !important; margin-right: auto !important; right: 8px !important; }
  .ant-message-notice-content { max-width: 92vw; }

  /* ---------- 底部导航 ---------- */
  #h5-nav {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 1200;
    display: flex;
    align-items: stretch;
    background: rgba(30, 41, 59, .97);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid rgba(148, 163, 184, .18);
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -6px 20px rgba(0, 0, 0, .22);
  }
  #h5-nav button {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 7px 2px 6px;
    background: none;
    border: 0;
    color: #94a3b8;
    font: inherit;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: color .15s, transform .1s;
  }
  #h5-nav button:active { transform: scale(.94); }
  #h5-nav button .i { font-size: 17px; line-height: 1; filter: grayscale(1); opacity: .75; }
  #h5-nav button .t { font-size: 10.5px; line-height: 1.1; letter-spacing: .2px; white-space: nowrap; }
  #h5-nav button.on { color: #4ade80; }
  #h5-nav button.on .i { filter: none; opacity: 1; }
  #h5-nav button.on::after {
    content: "";
    position: absolute;
    top: 0; width: 22px; height: 2px; border-radius: 0 0 3px 3px;
    background: #4ade80;
  }
  #h5-nav button { position: relative; }
  #h5-nav button .badge {
    position: absolute; top: 4px; right: 50%; transform: translateX(20px);
    min-width: 15px; height: 15px; padding: 0 3px;
    border-radius: 999px; background: #ff4d4f; color: #fff;
    font-size: 9.5px; line-height: 15px; text-align: center;
  }

  /* 账号中心悬浮按钮别被底部导航压住 */
  #account-center-entry { bottom: calc(78px + env(safe-area-inset-bottom)) !important; right: 12px !important; padding: 9px 14px !important; font-size: 13px !important; }
}

/* 超窄屏 (360 及以下) */
@media (max-width: 380px) {
  header.ant-layout-header > div:first-child > div { max-width: 28vw; font-size: 12px !important; }
  header .h5-online { font-size: 10.5px !important; padding: 2px 6px !important; }
  .h5-clock { font-size: 10px; }
  .h5k { width: 58px !important; min-width: 58px !important; }
}

/* ===== 2026-10-25 R2: 溢出收敛 / 表单单列 / 悬浮按钮 ===== */
@media (max-width: 991.98px) {
  /* 内容区底部留白，别被底部导航和悬浮按钮压住 */
  main.ant-layout-content { padding-bottom: 88px !important; }

  /* 工具条放不下时自动换行（刷新/删除/搜索 挤成一坨的那种） */
  .h5wrap { flex-wrap: wrap !important; max-width: 100% !important; row-gap: 8px !important; }
  .h5wrap > * { min-width: 0 !important; }
  .h5wrap .ant-input-affix-wrapper,
  .h5wrap .ant-input-search,
  .h5wrap .ant-select,
  .h5wrap .ant-picker {
    flex: 1 1 100% !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  .h5wrap .ant-input { width: 100% !important; }
  .ant-input::placeholder { font-size: 12px !important; }

  /* 表单两列 → 单列 */
  .h5colfull { flex: 0 0 100% !important; max-width: 100% !important; }
  .h5colfull > div { flex-wrap: wrap !important; }
  .h5colfull textarea { min-height: 70px !important; }

  /* 账号中心 → 圆形小钮（不再压内容） */
  #account-center-entry {
    width: 44px !important;
    height: 44px !important;
    padding: 0 !important;
    border-radius: 50% !important;
    right: 10px !important;
    bottom: calc(70px + env(safe-area-inset-bottom)) !important;
    justify-content: center !important;
    font-size: 0 !important;
    opacity: .94;
  }
  #account-center-entry span { font-size: 16px !important; }
}
