/* 康賢後台手機適配（只喺窄屏生效，桌面版完全唔變）*/
@media (max-width: 860px) {

  /* 後台外框：左右 → 上下 */
  .min-h-screen.bg-medical-bg.flex:has(> aside.w-64) {
    flex-direction: column;
  }

  /* Sidebar 變頂部區塊，全寬 */
  aside.w-64 {
    width: 100% !important;
    border-right: 0 !important;
    border-bottom: 1px solid rgba(0,0,0,.08);
  }

  /* 標題區縮細 */
  aside.w-64 > div.p-6 {
    padding: .75rem 1rem;
  }
  aside.w-64 > div.p-6 h1 {
    font-size: 1rem;
  }

  /* 菜單：直排 → 橫向可滑動 */
  aside.w-64 > nav {
    display: flex;
    gap: .375rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: .5rem .75rem;
  }
  aside.w-64 > nav a {
    white-space: nowrap;
    padding: .5rem .875rem !important;
    font-size: .8125rem;
    flex-shrink: 0;
  }

  /* 底部（返回前台/退出）：橫排 */
  aside.w-64 > div.p-4.border-t {
    display: flex;
    gap: .5rem;
    padding: .5rem .75rem;
    border-top: 0 !important;
  }
  aside.w-64 > div.p-4.border-t a,
  aside.w-64 > div.p-4.border-t button {
    width: auto !important;
    padding: .375rem .75rem !important;
    font-size: .8125rem;
  }

  /* 內容區：縮 padding */
  main.overflow-auto > div {
    padding: 1rem !important;
  }

  /* 表格容器：准橫向滾動，表格保留最小寬度 */
  main.overflow-auto div.overflow-hidden:has(> table) {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  main.overflow-auto table {
    min-width: 560px;
  }

  /* 表頭同徽章：唔好斷行 */
  main.overflow-auto table th {
    white-space: nowrap;
  }
  main.overflow-auto table td span[class*="rounded"] {
    white-space: nowrap;
  }

  /* 第二欄（醫生名/類型）保留最小寬度，唔好迫到直排 */
  main.overflow-auto table td:nth-child(2) {
    min-width: 110px;
  }

  /* 編輯表單兩欄 → 單欄 */
  main.overflow-auto .grid.grid-cols-2 {
    grid-template-columns: 1fr;
  }

  /* 彈窗：貼邊唔好頂死 */
  div.max-w-2xl.max-h-\[90vh\] {
    margin: 1rem;
    max-width: calc(100vw - 2rem) !important;
  }

  /* 頁首標題+按鈕行：准換行 */
  main.overflow-auto div.flex.items-center.justify-between {
    flex-wrap: wrap;
    gap: .5rem;
  }
}
