/* =========================================================
   手机端独立界面（≤820px）
   与桌面 style.css 解耦，避免窄屏被桌面布局挤乱
   ========================================================= */

@media (max-width: 820px) {
  html, body {
    overflow-x: clip !important;
    width: 100% !important;
    max-width: 100vw !important;
  }

  /* ---------- 顶栏：单行精简 ---------- */
  .topbar {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: space-between !important;
    height: 52px !important;
    min-height: 52px !important;
    max-height: 52px !important;
    padding: 0 10px !important;
    gap: 8px !important;
    position: sticky !important;
    top: 0 !important;
    z-index: 100 !important;
    background: #fff !important;
  }

  .brand {
    display: flex !important;
    align-items: center !important;
    flex: 0 0 auto !important;
    min-width: 0 !important;
    max-width: 36% !important;
  }

  .brand-logo {
    font-size: 15px !important;
    letter-spacing: 0.3px !important;
    white-space: nowrap !important;
  }

  .brand-name {
    display: none !important;
  }

  .topnav {
    display: flex !important;
    flex: 1 1 auto !important;
    margin-left: 0 !important;
    gap: 4px !important;
    min-width: 0 !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap !important;
  }

  .topnav a {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex: 0 0 auto !important;
    height: 32px !important;
    padding: 0 10px !important;
    margin: 0 !important;
    border-radius: 8px !important;
    font-size: 13px !important;
    white-space: nowrap !important;
    writing-mode: horizontal-tb !important;
    transform: none !important;
    position: static !important;
    float: none !important;
  }

  .topuser {
    display: flex !important;
    flex: 0 0 auto !important;
    margin-left: 0 !important;
    max-width: 42px !important;
  }

  .user-menu-name,
  .user-menu-caret {
    display: none !important;
  }

  .user-menu-trigger {
    padding: 2px !important;
    border: none !important;
  }

  /* ---------- 页面容器 ---------- */
  .page {
    margin: 10px auto !important;
    padding: 0 10px !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  .card {
    padding: 12px !important;
    margin-bottom: 10px !important;
    overflow: hidden !important;
  }

  .crumb {
    font-size: 12px !important;
    margin-bottom: 8px !important;
  }

  /* ---------- 方案列表：强制卡片，隐藏宽表 ---------- */
  .page-list .list-desktop,
  .page-list .table-wrap.list-desktop,
  .page-list table.grid {
    display: none !important;
  }

  .page-list .list-mobile,
  .page-list .sol-card-list {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
  }

  .sol-card {
    display: block !important;
    border: 1px solid #e3e8f0 !important;
    border-radius: 12px !important;
    padding: 14px !important;
    background: #fff !important;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.04) !important;
  }

  .sol-card-top {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    margin-bottom: 8px !important;
  }

  .sol-card-idx {
    font-size: 12px !important;
    color: #6b7686 !important;
  }

  .sol-card-title {
    display: block !important;
    font-size: 16px !important;
    font-weight: 650 !important;
    line-height: 1.35 !important;
    margin-bottom: 10px !important;
    color: #1f2733 !important;
    word-break: break-word !important;
  }

  .sol-card-meta {
    display: grid !important;
    gap: 8px !important;
    margin-bottom: 12px !important;
    padding: 10px 12px !important;
    background: #f7f9fd !important;
    border-radius: 8px !important;
  }

  .sol-card-meta > div {
    display: flex !important;
    justify-content: space-between !important;
    gap: 10px !important;
    align-items: flex-start !important;
  }

  .sol-card-meta .k {
    flex: 0 0 auto !important;
    min-width: 64px !important;
    color: #6b7686 !important;
    font-size: 12px !important;
  }

  .sol-card-meta .v {
    flex: 1 1 auto !important;
    text-align: right !important;
    font-size: 13px !important;
    color: #1f2733 !important;
    word-break: break-word !important;
  }

  .sol-card-ops {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
  }

  .sol-card-ops .ops {
    width: 100% !important;
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
  }

  .sol-card-ops .mini {
    height: 36px !important;
    margin: 0 !important;
    border-radius: 8px !important;
    font-size: 13px !important;
    flex: 1 1 auto !important;
  }

  .list-toolbar {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    margin-bottom: 12px !important;
  }

  .list-toolbar .search {
    width: 100% !important;
    max-width: none !important;
    flex: 1 1 100% !important;
    height: 40px !important;
    font-size: 16px !important;
  }

  .list-toolbar .spacer {
    display: none !important;
  }

  .list-toolbar .btn-primary,
  .list-toolbar .btn-ghost {
    flex: 1 1 calc(50% - 4px) !important;
    height: 40px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 12px !important;
    line-height: 1 !important;
  }

  /* ---------- 编辑页常用块 ---------- */
  .edit-body {
    display: block !important;
  }

  .edit-preview {
    position: static !important;
    margin-top: 12px !important;
  }

  .eq-row {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px !important;
  }

  .eq-cell label {
    position: static !important;
    display: block !important;
    margin-bottom: 6px !important;
  }

  .eq-row .op {
    text-align: center !important;
    padding: 0 !important;
  }

  .grid3 {
    grid-template-columns: 1fr !important;
  }

  .info-grid {
    grid-template-columns: 1fr !important;
  }

  .device-cards {
    grid-template-columns: 1fr !important;
  }

  .page-actions .btn-primary.lg,
  .page-actions .btn-ghost.lg {
    width: 100% !important;
    margin-left: 0 !important;
  }

  .admin-layout {
    grid-template-columns: 1fr !important;
  }

  .modal-body {
    grid-template-columns: 1fr !important;
  }

  input[type="text"],
  input[type="number"],
  input[type="password"],
  select,
  textarea {
    font-size: 16px !important;
  }

  .table-wrap,
  .wiring-wrap,
  .topo-wrap {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    max-width: 100% !important;
  }

  /* 推荐方案卡片：横向滑动由 pkg-strip 承担，外层勿裁切 */
  .solution-table-wrap {
    overflow-x: visible !important;
    max-width: 100% !important;
  }

  .pkg-gallery {
    gap: 4px;
    align-items: stretch;
    width: 100%;
  }

  .pkg-strip {
    gap: 12px;
    padding: 4px 2px 14px;
    scroll-snap-type: x mandatory;
  }

  .pkg-card {
    display: flex;
    flex-direction: column;
    flex: 0 0 100%;
    width: 100%;
    min-height: auto;
    scroll-snap-align: center;
  }

  .pkg-ribbon {
    font-size: 12px;
    padding: 6px 14px 6px 10px;
  }

  .pkg-type-badge {
    position: static;
    order: 1;
    margin: 36px 10px 6px;
    font-size: 15px;
    font-weight: 700;
    padding: 7px 12px;
    white-space: normal;
    word-break: break-word;
    text-align: center;
    align-self: stretch;
    max-width: none;
  }

  .pkg-body {
    order: 2;
    padding: 6px 12px 14px;
    min-height: auto;
  }

  .pkg-stack {
    grid-template-columns: 1fr;
    gap: 10px;
    padding-right: 0;
  }

  .pkg-row b {
    font-size: 13px;
  }

  .pkg-rack-wrap {
    position: static;
    margin-top: 8px;
    text-align: center;
  }

  .pkg-rack,
  .pkg-img,
  .pkg-ph {
    width: 72px;
    height: 48px;
    margin: 0 auto;
  }

  .pkg-swap {
    position: static;
    display: inline-block;
    margin-top: 6px;
  }

  .pkg-caret {
    bottom: 4px;
  }
}

/* 桌面端：隐藏手机卡片列表 */
@media (min-width: 821px) {
  .list-mobile {
    display: none !important;
  }
}

/* ---------- 移动端侧边栏默认收起 ---------- */
@media (max-width: 820px) {
  .sidebar { margin-left: -224px; box-shadow: 2px 0 12px rgba(0,0,0,.12); }
  .main-wrap { margin-left: 0; }
  body.side-collapsed .sidebar { margin-left: 0; }
  body.side-collapsed.is-mobile { overflow: hidden; }
  .side-brand { justify-content: flex-start; padding: 0 6px 0 12px; gap: 8px; }
  .side-close {
    display: inline-flex; align-items: center; justify-content: center;
    margin-left: auto; width: 36px; height: 36px; border: none; background: none;
    font-size: 26px; line-height: 1; color: #64748b; cursor: pointer; border-radius: 8px;
  }
  .side-close:hover { background: #f2f6fd; color: var(--primary); }
  .side-backdrop {
    display: none; position: fixed; inset: 0; background: rgba(15, 23, 42, .42);
    z-index: 55; border: none; padding: 0; margin: 0; cursor: pointer;
  }
  body.side-collapsed .side-backdrop { display: block; }
  .topbar2 { height: 52px; padding: 0 12px; }
  .main-content { padding: 0; }
  .page { margin: 12px auto; padding: 0 12px; }
  .tu-name { display: none; }
  .page-title { font-size: 15px; }
  .calc-tabs { flex-wrap: wrap; }
  .calc-tab { flex: 1 1 30%; min-width: 96px; }
  .eq-row { flex-direction: column; align-items: stretch; }
  .eq-row .op { display: none; }
  .preview-stats { grid-template-columns: 1fr 1fr; }
  .wizard { width: 100%; }
  .sticky-actions .btn-primary.lg { width: 100%; margin-left: 0; }
}
