/* 移动端适配：把桌面端的左侧栏/表格/头部在窄屏下改成纵向布局。 */
@media (max-width: 820px) {
  html, body { max-width: 100%; overflow-x: hidden; }

  /* 顶部栏允许换行，别把用户信息/退出按钮挤没 */
  header {
    flex-wrap: wrap !important;
    gap: 10px;
    padding: 10px 12px !important;
  }
  header > div { min-width: 0; }
  header .space-x-4 { flex-wrap: wrap; gap: 8px; }

  /* 总代后台/分代后台主容器: 侧栏和内容改成上下排列 */
  .max-w-\[1600px\],
  .max-w-\[1500px\] {
    max-width: 100% !important;
    padding-left: 10px !important;
    padding-right: 10px !important;
    gap: 12px !important;
  }
  .max-w-\[1600px\].flex,
  .flex-1.flex.max-w-\[1600px\] {
    flex-direction: column !important;
  }

  /* 左侧导航变成横向可滑动的一排 */
  aside.w-60 {
    width: 100% !important;
    flex-shrink: 0 !important;
    flex-direction: row !important;
    gap: 8px !important;
  }
  aside.w-60 nav {
    display: flex !important;
    flex-direction: row !important;
    overflow-x: auto !important;
    gap: 6px !important;
    padding: 8px !important;
    width: 100%;
    -webkit-overflow-scrolling: touch;
  }
  aside.w-60 nav button {
    width: auto !important;
    flex: 0 0 auto !important;
    white-space: nowrap !important;
    padding: 8px 12px !important;
  }
  aside.w-60 > .glass-panel.mt-auto {
    display: none !important;   /* 只隐藏“服务运行状态”面板，导航保留 */
  }

  main { width: 100% !important; min-width: 0 !important; }

  /* 表格: 窄屏下允许横向滑动，不再硬挤 */
  .glass-panel table { min-width: 680px; }
  .glass-panel:has(table) { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* 弹窗别超出屏幕 */
  .swal2-popup {
    width: 94vw !important;
    max-width: 94vw !important;
    padding: 1.1em !important;
  }
  .swal2-title { font-size: 16px !important; }
  .swal2-html-container { font-size: 12px !important; }

  /* 登录卡片缩小内边距 */
  .max-w-md { padding-left: 18px !important; padding-right: 18px !important; }
}

@media (max-width: 480px) {
  header h1 { font-size: 14px !important; }
  header p { display: none; }
  .glass-panel { border-radius: 12px !important; }
  main { padding-left: 0 !important; padding-right: 0 !important; }
}
