/* =========================================================
   手機版面

   所有規則都掛在 html.view-mobile 底下，而不是直接用 @media：
   「自動偵測」（螢幕寬度 <= 768px 且主要輸入方式是觸控）和「手動切換」都只是在決定要不要加這個 class，
   見 components/shared/viewMode.js。因此在電腦瀏覽器選「手機版」也能預覽。

   這個檔案要最後載入，才能蓋過各頁自己的電腦版樣式。
   這一版只做「共用框架」：側欄抽屜、頁首、彈出視窗、表單、表格、行事曆。
   各頁面（潛在客戶、訊息、訂單…）要再個別調整，進度見 docs/mobile.md。
========================================================= */

/* ---------- 整體版面 ---------- */

html.view-mobile .layout {
    width: 100%;
    height: 100vh;
    height: 100dvh; /* 手機瀏覽器的網址列會伸縮，dvh 才不會被蓋住底部 */
}

/* ---------- 側欄 → 左側抽屜 ---------- */

html.view-mobile #sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1100;
    width: min(300px, 85vw);
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: none;
}

html.view-mobile.sidebar-open #sidebar {
    transform: translateX(0);
    box-shadow: 8px 0 28px rgba(0, 0, 0, .35);
}

html.view-mobile .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1090;
    background: rgba(0, 0, 0, .4);
}

html.view-mobile.sidebar-open .sidebar-backdrop {
    display: block;
}

html.view-mobile .mobile-only {
    display: flex;
}

html.view-mobile .sidebar-footer-actions {
    gap: 8px;
}

html.view-mobile #sidebar .sidebar-footer-actions button {
    flex: 1;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, .25);
}

/* 手指要點得到：選單項目至少 44px 高 */
html.view-mobile #sidebar button {
    min-height: 44px;
}

html.view-mobile .app-switcher-menu {
    width: min(300px, calc(100vw - 24px));
}

/* ---------- 頁首 ---------- */

html.view-mobile header {
    height: auto;
    min-height: 56px;
    gap: 8px;
    padding: 8px 12px;
}

html.view-mobile .mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    padding: 0;
    font-size: 22px;
    line-height: 1;
    color: #1f2937;
    background: transparent;
    border: 1px solid #ddd;
}

html.view-mobile .global-search-wrap {
    flex: 1;
    min-width: 0;
}

html.view-mobile header input {
    width: 100%;
    min-width: 0;
}

/* 頁首放不下「歡迎、姓名、個人資料、登出」：只留通知鈴，其餘移到抽屜裡 */
html.view-mobile .user-greeting,
html.view-mobile #currentUserName,
html.view-mobile #userInfo > button {
    display: none;
}

html.view-mobile #userInfo {
    flex-shrink: 0;
    gap: 0;
}

html.view-mobile .notif-bell-btn {
    min-width: 44px;
    min-height: 44px;
}

/* 搜尋結果、通知面板：原本是固定寬度往右展開，小螢幕會被切掉，改成貼齊畫面左右 */
html.view-mobile .global-search-panel,
html.view-mobile .notif-panel {
    position: fixed;
    top: 64px;
    left: 12px;
    right: 12px;
    width: auto;
    max-height: calc(100dvh - 80px);
}

/* ---------- 內容 ---------- */

html.view-mobile main {
    padding: 12px;
}

html.view-mobile h1 {
    font-size: 22px;
    margin-bottom: 12px;
}

html.view-mobile .page-header {
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 14px;
}

html.view-mobile .dashboard-section {
    max-width: none;
}

/* ---------- 按鈕與表單 ---------- */

html.view-mobile main button,
html.view-mobile .modal button {
    min-height: 44px;
}

/* 輸入框字級小於 16px，iPhone 點進去會自動放大畫面 */
html.view-mobile input,
html.view-mobile select,
html.view-mobile textarea {
    font-size: 16px;
}

/* 勾選框、圓形選項不要撐成 44px，否則清單會被拉得很長 */
html.view-mobile input:not([type="checkbox"]):not([type="radio"]),
html.view-mobile select {
    min-height: 44px;
}

html.view-mobile input[type="checkbox"],
html.view-mobile input[type="radio"] {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* ---------- 表格：太寬就在表格內橫向捲動，不要把欄位擠爛 ---------- */

html.view-mobile main table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

html.view-mobile main th,
html.view-mobile main td {
    white-space: nowrap;
    padding: 12px;
}

/* ---------- 彈出視窗 → 滿版 ---------- */

html.view-mobile .modal {
    align-items: stretch;
}

/* 各彈窗有自己的 .modal-content:has(...) 寬度（specificity 0,2,0），
   這裡 0,2,1 一律蓋過它們 */
html.view-mobile .modal-content {
    width: 100vw;
    max-height: none;
    height: 100vh;
    height: 100dvh;
    border-radius: 0;
}

html.view-mobile #modal-body {
    padding: 16px;
}

html.view-mobile .modal-footer,
html.view-mobile .confirm-actions {
    flex-wrap: wrap;
}

/* ---------- 行事曆（FullCalendar） ---------- */

html.view-mobile #calendar {
    padding: 8px;
}

html.view-mobile .fc .fc-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
}

html.view-mobile .fc .fc-toolbar-chunk {
    display: flex;
    justify-content: center;
}

html.view-mobile .fc .fc-toolbar-title {
    font-size: 18px;
    text-align: center;
}

html.view-mobile .fc .fc-button {
    min-height: 40px;
}

/* =========================================================
   潛在客戶：每一列排成一張卡片
   寬表格在手機上要左右滑，滑到「階段」時姓名已經看不到，不知道是誰。
   改成卡片：姓名當標題，其餘欄位兩欄排列，欄位名稱來自儲存格的 data-label
   （components/lead/leadsTable.js）。整張卡片點下去仍然開啟客戶資料。
========================================================= */

html.view-mobile .leads-table-wrap {
    overflow: visible;
    background: transparent;
    border-radius: 0;
}

html.view-mobile .leads-table,
html.view-mobile .leads-table tbody {
    display: block;
    overflow: visible;
}

html.view-mobile .leads-table thead,
html.view-mobile .leads-table .leads-table-spacer {
    display: none;
}

html.view-mobile .leads-table tbody tr.lead-row {
    position: relative;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 12px;
    margin-bottom: 10px;
    padding: 14px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
}

html.view-mobile .leads-table tbody tr.lead-row:active {
    background: #f5f7fb;
}

html.view-mobile .leads-table td {
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: auto;
    max-width: none;
    min-width: 0;
    padding: 0;
    font-size: 15px;
    color: #111827;
    white-space: normal;
    overflow: visible;
    overflow-wrap: anywhere;
    text-overflow: clip;
    background: transparent;
    border: 0;
    /* 電腦版的「固定欄位」是用 JS 平移，手機版不需要 */
    transform: none !important;
}

html.view-mobile .leads-table td::before {
    content: attr(data-label);
    font-size: 12px;
    color: #6b7280;
}

/* 姓名：卡片標題，不需要欄位名稱；右邊留位置給刪除鈕 */
html.view-mobile .leads-table td[data-key="name"] {
    grid-column: 1 / -1;
    padding-right: 48px;
    font-size: 17px;
    font-weight: 600;
}

html.view-mobile .leads-table td[data-key="name"]::before {
    display: none;
}

/* Email 通常很長，獨占一行 */
html.view-mobile .leads-table td[data-key="email"] {
    grid-column: 1 / -1;
}

/* 排列順序：姓名 → 電話、階段 → Email → 其餘欄位（日期、來源、負責業務、自訂欄位） */
html.view-mobile .leads-table td[data-key="name"] { order: -4; }
html.view-mobile .leads-table td[data-key="phone"] { order: -3; }
html.view-mobile .leads-table td[data-key="stage"] { order: -2; }
html.view-mobile .leads-table td[data-key="email"] { order: -1; }

/* 沒有內容的欄位（顯示成「-」）直接不顯示，卡片才不會又長又空。姓名一定留著 */
html.view-mobile .leads-table td.leads-cell-empty:not([data-key="name"]) {
    display: none;
}

html.view-mobile .leads-table td.leads-table-actions {
    position: absolute;
    top: 6px;
    right: 6px;
    display: flex;
    flex-direction: row;
    width: auto;
    max-width: none;
}

html.view-mobile .leads-table td.leads-table-actions::before {
    display: none;
}

html.view-mobile .leads-table-trash {
    min-width: 44px;
    min-height: 44px;
    font-size: 18px;
}

/* =========================================================
   客戶資料彈窗（潛在客戶／客戶共用）
   頭像原本在欄位左邊，手機上會把欄位擠到只剩 220px；改成頭像在上、欄位滿寬
========================================================= */

html.view-mobile .lead-essentials {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
}

html.view-mobile .lead-essentials-fields {
    flex: none;
    width: 100%;
}

html.view-mobile .lead-section {
    padding: 12px;
}

/* 潛在客戶的篩選列：選項在手機上直接攤開、自動換行，不要再塞進有捲軸的小框 */
html.view-mobile .leads-filter-value {
    flex: 1 1 100%;
}

html.view-mobile .leads-filter-multiselect {
    max-width: none;
    max-height: none;
    overflow: visible;
}

html.view-mobile .leads-filter-multiselect-option {
    min-height: 44px;
}

/* =========================================================
   銷售流程（看板）
   手機沒辦法拖曳卡片，而且 5～7 個 320px 寬的欄位也塞不下。改成：
   - 頂端階段標籤（有人數），一次只顯示選到的那個階段
   - 每張卡片底下有「‹ 上一階段」「下一階段 ›」，按下去走原本的轉換視窗
   JS：components/kanban.js
========================================================= */

html.view-mobile .pipeline-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    margin-bottom: 14px;
}

html.view-mobile .pipeline-filter {
    flex-wrap: wrap;
}

html.view-mobile .pipeline-filter .searchable-select {
    flex: 1;
    min-width: 0;
    width: auto;
}

/* 電腦版用來「看到被切掉的欄位」的第二條捲軸，手機版不需要 */
html.view-mobile .kanban-top-scroll {
    display: none;
}

html.view-mobile #kanban {
    display: block;
    overflow: visible;
    padding-bottom: 80px; /* 留位置給底部的批次移動列 */
}

/* 階段標籤：橫向可滑，選到的那個反白 */
html.view-mobile .kanban-stage-tabs {
    display: flex;
    gap: 8px;
    margin: 0 -12px 12px;
    padding: 0 12px 4px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

html.view-mobile .kanban-stage-tabs::-webkit-scrollbar {
    display: none;
}

html.view-mobile .kanban-stage-tab {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 14px;
    font-size: 15px;
    color: #374151;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 999px;
    white-space: nowrap;
}

html.view-mobile .kanban-stage-tab.active {
    color: #fff;
    background: #1f2937;
    border-color: #1f2937;
}

html.view-mobile .kanban-stage-tab-count {
    padding: 1px 8px;
    font-size: 13px;
    color: #374151;
    background: #e5e7eb;
    border-radius: 999px;
}

html.view-mobile .kanban-stage-tab.active .kanban-stage-tab-count {
    color: #1f2937;
    background: #fff;
}

/* 一次只顯示一個階段、占滿寬度，高度跟著內容走（不要再各自有 550px 的內部捲動） */
html.view-mobile .kanban-column {
    display: none;
    width: 100%;
    min-width: 0;
    padding: 12px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
}

html.view-mobile .kanban-column.kanban-column-active {
    display: block;
}

html.view-mobile .kanban-body {
    min-height: 0;
    max-height: none;
    overflow: visible;
}

html.view-mobile .kanban-search-input {
    min-height: 44px;
}

html.view-mobile .kanban-quick-add {
    min-width: 44px;
    min-height: 44px;
    font-size: 18px;
}

/* 卡片：姓名、電話在上，底下一排「上一階段／下一階段」 */
/* css/leads.css 還留著舊的 .lead-card{display:flex} 與 .lead-name{26px}：改成上下排列、姓名縮小 */
html.view-mobile .lead-card {
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    padding: 12px 52px 12px 4px;
}

html.view-mobile .kanban-body .lead-name {
    font-size: 17px;
}

html.view-mobile .lead-card-checkbox {
    width: 22px;
    height: 22px;
}

html.view-mobile .lead-card-trash {
    top: 4px;
    right: 4px;
    min-width: 44px;
    min-height: 44px;
    font-size: 18px;
}

html.view-mobile .lead-card-move {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-top: 10px;
}

html.view-mobile .lead-card-move-btn {
    flex: 1;
    min-width: 0;
    padding: 0 10px;
    font-size: 14px;
    color: #1f2937;
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

html.view-mobile .lead-card-move-btn:active {
    background: #e5e7eb;
}

html.view-mobile .lead-card-move-spacer {
    flex: 1;
}

/* 批次移動列：電腦版是浮在底部中間的膠囊，手機版改成貼齊左右、放不下就換行 */
html.view-mobile .bulk-action-bar {
    left: 12px;
    right: 12px;
    bottom: 12px;
    transform: none;
    flex-wrap: wrap;
    border-radius: 16px;
}

html.view-mobile .bulk-action-bar select {
    flex: 1;
    min-width: 0;
}

/* =========================================================
   移動階段的轉換視窗（銷售流程拖曳／按「上一階段、下一階段」都會開）
   欄位名稱在上、輸入框滿寬；取消／確認並排撐滿
========================================================= */

html.view-mobile .transition-modal {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

html.view-mobile .transition-section h3 {
    margin: 0 0 8px;
}

html.view-mobile .transition-modal .required-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

html.view-mobile .transition-modal .required-item input:not([type="checkbox"]):not([type="radio"]),
html.view-mobile .transition-modal .required-item select,
html.view-mobile .transition-modal .required-item textarea {
    width: 100%;
}

html.view-mobile .transition-modal .modal-footer {
    display: flex;
    gap: 12px;
}

html.view-mobile .transition-modal .modal-footer button {
    flex: 1;
}

/* =========================================================
   FullCalendar（行事曆、排班）
   上面「main table」那條規則會把表格改成 display:block 並讓格子不換行——對一般資料表是
   對的，但 FullCalendar 整個月曆就是用表格排版，被改掉格子就塌成一條線。這裡還原。
========================================================= */

html.view-mobile .fc table {
    display: table;
    overflow: visible;
}

html.view-mobile .fc th,
html.view-mobile .fc td {
    padding: 0;
    white-space: normal;
}

/* 月檢視的小圓點行程、「還有 n 筆」：手機上字小一點，格子才放得下 */
html.view-mobile .fc .fc-daygrid-event {
    font-size: 11px;
}

html.view-mobile .fc .fc-daygrid-more-link {
    font-size: 11px;
}

/* 列表檢視：一筆一列，整列好點 */
html.view-mobile .fc .fc-list-event td {
    padding: 12px 10px;
}

html.view-mobile .fc .fc-list-day-cushion {
    padding: 10px;
}

/* 沒有行程時的提示 */
html.view-mobile .fc .fc-list-empty {
    padding: 32px 12px;
}

html.view-mobile .fc .fc-list-event-time {
    white-space: nowrap;
}

/* 行事曆／排班頁首的下拉選單與「新增」按鈕：放不下就換行，按鈕文字不要折成兩行 */
html.view-mobile .appointments-header-actions {
    flex-wrap: wrap;
}

html.view-mobile .appointments-header-actions button,
html.view-mobile #newShiftBtn {
    white-space: nowrap;
}

/* =========================================================
   排班（主管的週表格，pages/hrShifts.js）
   電腦是「員工 × 七天」的表格；手機放不下七欄，改成一位員工一張卡片，底下列出七天，
   每一天一列、整列好點（點空白處或「＋」新增、點班別編輯）。
========================================================= */

html.view-mobile .shift-grid {
    min-width: 0;
}

html.view-mobile .shift-head-row {
    display: none;
}

html.view-mobile .shift-row {
    display: block;
    margin-bottom: 12px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
}

html.view-mobile .shift-name-cell {
    padding: 10px 12px;
    background: #f9fafb;
    border-right: none;
    border-bottom: 1px solid #e5e7eb;
}

html.view-mobile .shift-cell {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    min-height: 48px;
    padding: 6px 12px;
    border-right: none;
    border-bottom: 1px solid #f3f4f6;
}

html.view-mobile .shift-cell:last-child {
    border-bottom: none;
}

html.view-mobile .shift-cell::before {
    content: attr(data-label);
    flex: 0 0 56px;
    color: #6b7280;
    font-size: 13px;
}

html.view-mobile .shift-cell.is-today::before {
    color: var(--primary-color, #2563eb);
    font-weight: 700;
}

/* 手機沒有「滑過」，「＋」一直顯示，推到最右邊 */
html.view-mobile .shift-add {
    position: static;
    align-self: center;
    margin-top: 0;
    opacity: 1;
    width: 44px;
    height: 44px;
    margin-left: auto;
}

html.view-mobile .shift-chip {
    width: auto;
    flex: 1 1 120px;
    min-height: 44px;
}

/* =========================================================
   訊息
   手機版一次只顯示一個畫面：對話列表 → 點一個對話 → 聊天畫面（左上「← 返回」回列表）。
   JS 在選到對話時，替 .messages-page 加上 has-thread。
========================================================= */

/* 高度 = 螢幕 − 頁首(56) − main 的上下留白(24)，聊天室才不會被撐出畫面 */
html.view-mobile .messages-page {
    height: calc(100dvh - 90px);
    min-height: 320px;
    flex-direction: column;
}

html.view-mobile .messages-list-pane {
    width: 100%;
    flex: 1;
    min-height: 0;
    border-right: none;
}

html.view-mobile .messages-page.has-thread .messages-list-pane,
html.view-mobile .messages-page.has-thread .messages-category-pane,
html.view-mobile .messages-page:not(.has-thread) .messages-thread {
    display: none;
}

/* 分類欄在手機上變成列表上方一排可以左右滑的小標籤；客戶資料面板不顯示（用「開啟客戶資料」） */
html.view-mobile .messages-category-pane {
    width: 100%;
    flex: none;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-right: none;
    border-bottom: 1px solid #eee;
    overflow-x: auto;
    overflow-y: hidden;
}

html.view-mobile .messages-category-pane h1 {
    margin: 0 4px 0 0;
    font-size: 18px;
    white-space: nowrap;
}

html.view-mobile #messageCategoryList {
    display: flex;
    gap: 6px;
}

html.view-mobile .messages-category-group {
    flex-direction: row;
    gap: 6px;
    margin-bottom: 0;
}

html.view-mobile .messages-category-title {
    display: none;
}

html.view-mobile .messages-category {
    width: auto;
    min-height: 36px;
    flex-shrink: 0;
    padding: 6px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 999px;
    white-space: nowrap;
}

html.view-mobile .messages-category.active {
    border-color: #bfdbfe;
}

html.view-mobile .messages-page .messages-customer-pane,
html.view-mobile .messages-page .messages-panel-toggle {
    display: none;
}

html.view-mobile .messages-thread {
    flex: 1;
    min-height: 0;
}

/* 列表頁首：搜尋框、篩選按鈕；篩選預設收起來 */
html.view-mobile .messages-list-header {
    padding: 12px;
}

html.view-mobile .messages-list-header h1 {
    margin-bottom: 8px;
}

html.view-mobile .messages-filters-toggle {
    display: block;
    width: 100%;
    margin-top: 8px;
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #e5e7eb;
}

html.view-mobile .messages-page:not(.filters-open) .messages-filters {
    display: none;
}

html.view-mobile #clearFilters {
    min-height: 44px;
}

/* 對話列表：整列好點，名字旁的徽章太多時換行 */
html.view-mobile .messages-item {
    min-height: 64px;
    padding: 12px;
}

html.view-mobile .messages-item-top strong {
    white-space: normal;
}

/* 聊天畫面頁首：返回鈕、頭像、名稱；「開啟客戶資料」放不下就換到下一行 */
html.view-mobile .messages-thread-header {
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 12px;
}

html.view-mobile .messages-back-btn {
    display: block;
    flex-shrink: 0;
    white-space: nowrap;
}

html.view-mobile .messages-thread-title {
    flex: 1 1 140px;
}

html.view-mobile .messages-thread-header #openLeadBtn,
html.view-mobile .messages-thread-header #addLeadBtn {
    flex: 1 1 100%;
    white-space: nowrap;
}

/* 負責人與結束對話：窄螢幕上下排列，下拉選單撐滿 */
html.view-mobile .messages-thread-toolbar {
    padding: 8px 12px;
}

html.view-mobile .messages-assign {
    flex: 1 1 100%;
}

html.view-mobile .messages-assign select {
    flex: 1;
    max-width: none;
}

html.view-mobile .messages-collab {
    flex: 1 1 100%;
}

/* 對話泡泡：手機上可以寬一點 */
html.view-mobile .messages-bubbles {
    padding: 12px;
}

html.view-mobile .message-row {
    max-width: 85%;
}

/* 回覆框：「按 Enter 傳送」在手機上不適用，說明文字拿掉；傳送鈕不要折行 */
html.view-mobile .messages-composer {
    padding: 8px 12px;
}

html.view-mobile .messages-composer .hint-desktop {
    display: none;
}

html.view-mobile .messages-composer-row button {
    flex-shrink: 0;
    white-space: nowrap;
}

/* 排班：週切換列的「複製上週／清空這一週」放不下就換行；傳送列上下排、按鈕滿寬 */
html.view-mobile .shift-week-nav {
    flex-wrap: wrap;
}

html.view-mobile .shift-week-actions {
    flex: 1 1 100%;
    margin-left: 0;
}

html.view-mobile .shift-week-actions button {
    flex: 1;
    white-space: nowrap;
}

html.view-mobile .shift-publish-bar {
    flex-direction: column;
    align-items: stretch;
}

html.view-mobile .shift-publish-btn {
    width: 100%;
}

/* 排班：員工多、卡片很長時，「傳送給團隊」固定在畫面底部，不用捲到最下面才找得到 */
html.view-mobile .shift-publish-bar {
    position: sticky;
    bottom: 0;
    z-index: 5;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, .08);
}

/* =========================================================
   業績（pages/hrPerformance.js）
   總覽卡片 2×2；全員業績每人一張卡片（點一下展開他的訂單）；訂單一筆一張小卡。
========================================================= */

html.view-mobile .perf-cards {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

html.view-mobile .perf-card {
    padding: 12px;
}

html.view-mobile .perf-card strong {
    font-size: 18px;
}

html.view-mobile .perf-tabs {
    max-width: none;
}

html.view-mobile .perf-toolbar {
    gap: 8px;
}

html.view-mobile .perf-field {
    flex: 1 1 140px;
}

html.view-mobile .perf-export {
    flex: 1 1 100%;
    margin-left: 0;
}

html.view-mobile .perf-person-head {
    display: none;
}

html.view-mobile .perf-people {
    border: none;
    background: transparent;
    overflow: visible;
}

html.view-mobile .perf-person {
    margin-bottom: 10px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
}

/* 一個人的卡片：名字一行，底下四項數字兩欄、佔比滿寬 */
html.view-mobile .perf-person-row {
    grid-template-columns: 1fr 1fr;
    gap: 6px 12px;
    padding: 12px;
    border-bottom: none;
}

html.view-mobile .perf-person-name {
    grid-column: 1 / -1;
    font-size: 16px;
}

html.view-mobile .perf-person-row [data-label]::before {
    content: attr(data-label) "　";
    color: #6b7280;
    font-size: 12px;
}

html.view-mobile .perf-share {
    grid-column: 1 / -1;
}

html.view-mobile .perf-share::before {
    display: none;
}

html.view-mobile .perf-orders-head {
    display: none;
}

/* 訂單：第一行「日期 ／ 狀態」，第二行客戶，第三行「金額 ／ 已收款」 */
html.view-mobile .perf-order {
    grid-template-columns: 1fr 1fr;
    gap: 4px 12px;
    padding: 10px 12px;
}

html.view-mobile .perf-order-date { order: 1; }
html.view-mobile .perf-order-status { order: 2; }
html.view-mobile .perf-order-customer { order: 3; }
html.view-mobile .perf-order-amount { order: 4; }
html.view-mobile .perf-order-paid { order: 5; }

html.view-mobile .perf-order-date {
    color: #6b7280;
    font-size: 13px;
}

html.view-mobile .perf-order-status {
    text-align: right;
}

html.view-mobile .perf-order-customer {
    grid-column: 1 / -1;
    font-size: 15px;
}

html.view-mobile .perf-order-amount,
html.view-mobile .perf-order-paid {
    text-align: left;
}

html.view-mobile .perf-order [data-label]::before {
    content: attr(data-label) "　";
    color: #6b7280;
    font-size: 12px;
}

/* 業績：分潤欄位與分潤規則設定（手機） */
html.view-mobile .perf-people.has-commission .perf-person-row {
    grid-template-columns: 1fr 1fr;
}

html.view-mobile .perf-orders.has-commission .perf-order {
    grid-template-columns: 1fr 1fr;
}

html.view-mobile .perf-order-commission {
    order: 6;
    grid-column: 1 / -1;
    flex-direction: row;
    align-items: baseline;
    gap: 8px;
}

html.view-mobile .perf-order-commission::before {
    content: attr(data-label) "　";
    color: #6b7280;
    font-size: 12px;
    font-weight: 400;
}

html.view-mobile .perf-rule-label {
    flex: 1 1 100%;
}

html.view-mobile .perf-rule-line select {
    flex: 1 1 140px;
}

html.view-mobile .perf-rule-line input {
    flex: 1 1 100px;
    width: auto;
}

html.view-mobile .perf-rule-line button {
    flex: 1 1 70px;
}

html.view-mobile .perf-rule-toggle {
    min-height: 56px;
}

/* 批次處理：勾選框與按鈕在手機上好點 */
html.view-mobile .messages-select {
    width: 22px;
    height: 22px;
}

html.view-mobile .messages-bulk-bar button {
    min-height: 40px;
}

html.view-mobile .bulk-assignee select {
    min-height: 40px;
}
