/* === 唯美特美容 管理後台 樣式 === */

:root {
    --brand: #b59367;
    --brand-dark: #8b6e47;
    --bg-soft: #faf6f0;
    --border: #e7e3dd;
    --text-main: #2e2a24;
    --text-muted: #8b8277;
    --danger: #c53030;
    --success: #2f855a;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC", "Microsoft JhengHei", sans-serif;
    color: var(--text-main);
    background: var(--bg-soft);
    min-height: 100vh;
}

a { color: var(--brand-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

/* === Layout === */

.admin-shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }

.sidebar {
    background: white;
    border-right: 1px solid var(--border);
    padding: 20px 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}
.sidebar-brand {
    padding: 0 20px 16px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 12px;
}
.sidebar-brand .logo {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--brand); color: white;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: bold; font-size: 16px; margin-right: 8px;
}
.sidebar-brand .name { font-weight: 600; color: var(--text-main); }
.sidebar-brand .sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.nav-link {
    display: flex; align-items: center;
    padding: 10px 20px;
    color: var(--text-main);
    transition: background 0.12s;
}
.nav-link:hover { background: var(--bg-soft); text-decoration: none; }
.nav-link.active {
    background: var(--bg-soft);
    color: var(--brand-dark);
    font-weight: 600;
    border-right: 3px solid var(--brand);
}
.nav-link .icon { margin-right: 10px; font-size: 16px; }

.main {
    padding: 24px 32px;
    max-width: 1400px;
    /* 2026-09-13 客戶錄影：手機上看板往右拉，時段欄連同頁首一起被拉走。
       .main 是 grid item，min-width 預設 auto → 會被寬表格的最小寬度撐開，
       變成「整頁」在橫向捲，而 .board-scroll 自己沒在捲，sticky 就沒有容器可黏。
       設 0 讓 .main 乖乖等於視窗寬，捲動才會回到 .board-scroll 裡面。 */
    min-width: 0;
}

/* === Page header === */

.page-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.page-header h1 { margin: 0; font-size: 22px; }
.page-header .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* === Buttons === */

.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 8px 16px; border-radius: 6px; border: 1px solid transparent;
    font-size: 14px; cursor: pointer; transition: background 0.15s, opacity 0.15s;
    text-decoration: none; white-space: nowrap;
}
.btn-primary { background: var(--brand); color: white; }
.btn-primary:hover { background: var(--brand-dark); text-decoration: none; color: white; }
.btn-secondary { background: white; border-color: var(--border); color: var(--text-main); }
.btn-secondary:hover { background: var(--bg-soft); text-decoration: none; }
.btn-danger { background: white; border-color: #fecaca; color: var(--danger); }
.btn-danger:hover { background: #fee2e2; text-decoration: none; }
.btn:disabled, .btn.disabled { opacity: 0.5; cursor: not-allowed; }

/* === Table === */

.table-card { background: white; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { background: var(--bg-soft); font-weight: 600; font-size: 13px; color: var(--text-muted); }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #fdfbf7; }

/* ── 預約看板：表頭與時段欄凍結（2026-08-25 客戶需求）──
   客戶原話：「我拉到這裡我已經忘記上面美容師是誰」。
   看板是「美容師 × 時段」的二維表，捲動時失去任一軸的標題就不知道自己在看誰的幾點。
   縱向捲 → 美容師那一列黏在頂端；橫向捲 → 時段那一欄黏在左側。
   左上角的交叉格必須有更高的 z-index，否則會被另一軸蓋住。 */
.board-scroll { overflow: auto; max-height: calc(100vh - 260px); }

.board-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    /* sticky 元素的 border 不會跟著移動，改用 box-shadow 畫分隔線 */
    box-shadow: inset 0 -1px 0 var(--border);
    background: var(--bg-soft);
}

.board-table tbody td:first-child,
.board-table thead th:first-child {
    position: sticky;
    left: 0;
    width: 90px;
    min-width: 90px;
    background: var(--bg-soft);
    box-shadow: inset -1px 0 0 var(--border);
}

/* 欄寬下限（2026-09-13）：美容師多時每欄會被壓到最窄，名字拆成一字一行、「＋ 空」擠成兩行。
   寧可表格寬一點多拉一下，也要每一格看得清楚。 */
.board-table th, .board-table td { min-width: 72px; }
.board-table thead th { white-space: nowrap; }

.board-table tbody td:first-child { z-index: 1; }
.board-table thead th:first-child { z-index: 3; }

/* 時段欄底色固定，否則 tr:hover 會讓它跟著變色、看起來像被選取 */
.board-table tr:hover td:first-child { background: var(--bg-soft); }

.table .question { font-weight: 500; color: var(--text-main); max-width: 360px; }
.table .keywords { font-size: 12px; color: var(--text-muted); }
.table .col-actions { width: 160px; text-align: right; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 12px; }
.badge-category { background: #f5ede0; color: var(--brand-dark); }
.badge-inactive { background: #fee2e2; color: var(--danger); }

/* === Form === */

.form-card { background: white; border: 1px solid var(--border); border-radius: 8px; padding: 24px; max-width: 860px; }
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-weight: 500; margin-bottom: 6px; font-size: 14px; }
.form-group .hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.form-control, select {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: inherit;
    background: white;
}
.form-control:focus, select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(181, 147, 103, 0.15); }
.form-control.textarea { min-height: 200px; resize: vertical; font-family: inherit; line-height: 1.6; }
.form-actions { display: flex; gap: 10px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }

/* 表單區塊標題與兩欄佈局（平板友善：窄屏自動單欄） */
.form-section { margin: 28px 0 14px; padding-bottom: 8px; border-bottom: 1px solid var(--border); font-size: 15px; font-weight: 600; color: var(--brand); }
.form-section:first-child { margin-top: 0; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
@media (max-width: 680px) { .form-row { grid-template-columns: 1fr; } }

/* === 排班月曆 === */
.cal-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-head { text-align: center; font-size: 12px; color: var(--text-muted); padding: 4px 0; font-weight: 600; }
.cal-cell { min-height: 64px; border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; cursor: pointer; background: white; transition: border-color .12s, box-shadow .12s; display: flex; flex-direction: column; gap: 4px; }
.cal-cell:hover { border-color: var(--brand); }
.cal-cell.empty { border: none; background: transparent; cursor: default; }
.cal-cell.sel { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(181,147,103,.3); }
.cal-cell .d { font-size: 13px; font-weight: 600; }
.cal-cell .st { font-size: 11px; }
.cal-cell.work { background: #f1f8f2; }
.cal-cell.off { background: #fbf0f0; color: #b06b6b; }
.cal-cell.none { background: #fafafa; color: var(--text-muted); }
/* 批次排班（2026-08-31）：圈選多天，一次套班別或一次設休假。
   .picked 放在 .work/.off/.none 之後，才蓋得掉那三個底色。 */
.cal-cell.picked { background: var(--brand); color: white; border-color: var(--brand); box-shadow: 0 0 0 2px rgba(181,147,103,.35); }
.cal-cell.picked .st { color: rgba(255,255,255,.85); }
.cal-cell.past { background: #f5f5f5; color: #c4c4c4; cursor: not-allowed; }
.cal-cell.past:hover { border-color: var(--border); }
.slot-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.slot-toggle { padding: 10px 16px; border: 1.5px solid var(--border); border-radius: 22px; background: white; cursor: pointer; font-size: 14px; font-family: inherit; min-width: 70px; transition: all .12s; }
.slot-toggle:hover { border-color: var(--brand); }
.slot-toggle.on { background: var(--brand); color: white; border-color: var(--brand); }
.tpl-list { display: flex; flex-direction: column; gap: 10px; }
.tpl-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.tpl-day { min-width: 44px; font-weight: 600; font-size: 14px; }
@media (max-width: 680px) { .cal-cell { min-height: 54px; padding: 4px; } .slot-toggle { padding: 12px 14px; } }

/* 全店排班總覽格子 */
.ov-cell { text-align: center; font-size: 11px; padding: 5px 3px; min-width: 28px; border-radius: 4px; }
.ov-work { background: #e6f4ea; color: var(--success); font-weight: 600; }
.ov-off { background: #fbf0f0; color: #b06b6b; }
.ov-none { color: #ccc; }

/* === Filter bar === */

.filter-bar { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; align-items: center; }
.filter-bar select, .filter-bar input { max-width: 280px; }

/* 手機（2026-09-28 客戶錄影 812262740）：一排 9 個控制項被擠成一格一個字，搜尋框只剩「搜」、下拉只剩箭頭。
   改成搜尋框獨佔一行、下拉兩個一排，每個都看得到完整文字 */
@media (max-width: 768px) {
    .filter-bar { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
    .filter-bar > input, .filter-bar > .form-control { grid-column: 1 / -1; }
    .filter-bar select, .filter-bar input { max-width: none !important; width: 100%; min-width: 0; }
}

/* 會員清單：勾選框＋姓名固定在左邊，表格往右滑時仍知道是哪一位（2026-09-28 客戶錄影 812262740） */
.customer-table .sticky-check,
.customer-table .sticky-name { position: sticky; z-index: 1; background: white; }
.customer-table th.sticky-check,
.customer-table th.sticky-name { z-index: 2; background: var(--bg-soft); }
.customer-table .sticky-check { left: 0; box-sizing: border-box; width: 40px; min-width: 40px; max-width: 40px; padding-left: 10px; padding-right: 6px; }
.customer-table .sticky-name { left: 40px; box-shadow: 3px 0 4px -3px rgba(0, 0, 0, 0.18); }
@media (max-width: 768px) {
    .customer-table .sticky-name { min-width: 116px; max-width: 132px; padding-left: 8px; padding-right: 8px; }
}

/* 手機保險（2026-10-03）：.table-card 的 overflow: hidden 會把超出螢幕的欄位直接裁掉、又不能滑，
   直拿手機時右邊的欄位與按鈕整個看不到。窄螢幕改成可左右滑，至少找得到。 */
@media (max-width: 1024px) {
    .table-card { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

/* 清單手機卡片版（2026-10-03 使用者要求：其他清單頁也改卡片）
   表格加 class="m-cards"，/js/mobile-cards.js 會把表頭欄名寫進每格的 data-label；
   窄螢幕時隱藏表頭，每列變一張卡片、每格一行「小標籤＋內容」。
   用 position:absolute 放標籤而不用 flex/grid：格子裡常有多個 div、徽章、按鈕，flex 會把它們排成一橫排。 */
@media (max-width: 768px) {
    .m-cards { min-width: 0 !important; }
    .m-cards > thead { display: none; }
    .m-cards, .m-cards > tbody { display: block; width: 100%; }
    .m-cards > tbody > tr { display: block; padding: 10px 14px; border-bottom: 1px solid var(--border); }
    .m-cards > tbody > tr:last-child { border-bottom: none; }
    /* 展開的編輯區／說明列接在上一張卡下面，不另起一張 */
    .m-cards > tbody > tr[data-m-sub] { padding-top: 0; }
    .m-cards > tbody > tr:has(+ tr[data-m-sub]) { border-bottom: none; }
    .table.m-cards > tbody > tr > td,
    .m-cards > tbody > tr > td {
        display: block; position: relative;
        padding: 3px 0 3px 6.5em; border: none;
        width: auto !important; max-width: none !important; min-width: 0 !important;
        white-space: normal !important; text-align: left !important;
        overflow-wrap: anywhere;
    }
    .m-cards > tbody > tr > td::before {
        content: attr(data-label);
        position: absolute; left: 0; top: 4px; width: 6em;
        font-size: 12px; color: var(--text-muted); font-weight: normal; line-height: 1.5;
    }
    /* 沒有欄名的欄（拖拉排序把手）手機用不到 */
    .m-cards > tbody > tr > td[data-label=""]:not([data-m]) { display: none; }
    .table.m-cards > tbody > tr > td[data-m],
    .m-cards > tbody > tr > td[data-m] { padding-left: 0; }
    .m-cards > tbody > tr > td[data-m]::before { content: none; }
    .m-cards > tbody > tr > td[data-m="title"] { font-size: 15px; font-weight: 600; color: var(--text-main); padding-bottom: 6px; }
    .m-cards > tbody > tr > td[data-m="actions"] { padding-top: 8px; }
    /* 動作格內常有 inline 的 justify-content:flex-end（桌機靠右），卡片裡要蓋掉才會跟其他卡一致靠左 */
    .m-cards > tbody > tr > td[data-m="actions"] > * { justify-content: flex-start !important; flex-wrap: wrap; }
    .m-cards > tbody > tr > td[data-m="full"] { padding: 6px 0; }

    /* 會員清單卡片：勾選框擺在姓名左邊（表頭欄名是空的，預設會被當拖拉把手藏起來，這裡要留著）；
       桌機的「固定在左側」陰影在卡片裡不需要 */
    .table.customer-table.m-cards > tbody > tr > td.sticky-check {
        display: block !important; float: left;
        padding: 2px 10px 0 0 !important; width: auto !important;
    }
    .customer-table.m-cards .sticky-check input { width: 20px; height: 20px; margin: 0; }
    /* 桌機 sticky 用的 left:40px 在 position:relative 下會把姓名往右推、撐出橫向捲軸；
       姓名格的白底＋z-index 會蓋住左邊浮動的勾選框，一併拿掉 */
    .customer-table.m-cards .sticky-check,
    .customer-table.m-cards .sticky-name { left: auto; box-shadow: none; z-index: auto; background: transparent; }
    .customer-table.m-cards td.sticky-name { font-weight: 600 !important; }
}
.m-only { display: none; }
@media (max-width: 768px) { .m-only { display: flex; } }

/* 對話監控手機版（2026-10-03 使用者回報：直拿只看得到客戶欄，要轉橫才看得到「訊息」「動作」）
   7 欄約 750px，手機直拿只有約 390px。改成一筆一張卡片，整張可點進檢視。 */
.convo-row { cursor: pointer; }
.convo-mobile-meta { display: none; }
.convo-avatar-cell, .convo-mtime, .convo-mfilter, .convo-mstores { display: none; }

/* 門市切換按鈕列（2026-10-25）：跟 .convo-mfilter 同時出現（手機、LINE 模式） */
.convo-mstore {
    flex: 1; padding: 6px 0; border: 1px solid var(--border, #e5dccd); border-radius: 999px;
    background: #fff; color: #6b5535; font-size: 14px; cursor: pointer;
}
.convo-mstore.active { background: #8b6f3e; border-color: #8b6f3e; color: #fff; font-weight: 600; }
@media (max-width: 768px) { .convo-mstores { display: flex; gap: 8px; margin-bottom: 12px; } }
@media (min-width: 769px) { .convo-line-mode .convo-mstores { display: flex; gap: 8px; margin-bottom: 12px; } }

/* 共用圓形頭貼：LINE 頭貼蓋在姓氏字上，圖片載不到（onerror 移除）就露出底下的字 */
.convo-avatar {
    position: relative; width: 48px; height: 48px; border-radius: 50%; overflow: hidden; flex-shrink: 0;
    background: #e9dcc6; color: #6b5535; font-weight: 600; font-size: 18px;
    display: inline-flex; align-items: center; justify-content: center;
}
.convo-avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

/* 2026-10-24 客戶錄影 LINE 官方帳號 App：手機列表改成 頭貼｜名字＋時間／最後一句／狀態，跟 LINE 一樣好認 */
@media (max-width: 768px) {
    .convo-mfilter { display: flex; gap: 8px; margin-bottom: 12px; }
    .convo-mfilter .form-control { flex: 1; min-width: 0; font-size: 16px; }
    .convo-mfilter .btn { flex-shrink: 0; }
    .convo-filter:not(.open) { display: none; }
    .convo-table thead { display: none; }
    .convo-table, .convo-table tbody { display: block; }
    .convo-table tr.convo-row {
        display: grid;
        grid-template-columns: 48px minmax(0, 1fr) auto;
        grid-template-areas:
            "avatar name    mtime"
            "avatar preview preview"
            "avatar state   state";
        gap: 2px 12px;
        padding: 12px 14px;
        border-bottom: 1px solid var(--border);
    }
    .convo-table tr.convo-row:active { background: #faf6ef; }
    .convo-table tr.convo-row:last-child { border-bottom: none; }
    .convo-table tr.convo-row td { display: block; padding: 0; border: none; max-width: none !important; }
    .convo-table .convo-avatar-cell { grid-area: avatar; align-self: start; padding-top: 2px; }
    .convo-table .convo-name { grid-area: name; font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .convo-table .convo-name > div { display: inline; margin-left: 4px; }
    .convo-table .convo-mtime { grid-area: mtime; font-size: 12px; color: var(--text-muted); align-self: center; white-space: nowrap; }
    /* 最後一句只留兩行、意圖只留一行（tr td 的 display:block 權重較高，這裡要寫到 td 才蓋得過） */
    .convo-table tr.convo-row td.convo-preview {
        grid-area: preview; font-weight: normal; color: var(--text-muted); font-size: 14px;
        overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere;
    }
    .convo-table .convo-state > div { flex-basis: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
    .convo-table .convo-state { grid-area: state; text-align: left; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-top: 4px; }
    .convo-table .convo-state > div { margin-top: 0 !important; }
    .convo-table .convo-mobile-meta { display: inline; font-size: 11px; color: var(--text-muted); }
    /* 桌機才需要的欄：開始/最後往來、門市、則數、檢視按鈕（手機整張卡片可點） */
    .convo-table .convo-time,
    .convo-table .convo-store,
    .convo-table .convo-count,
    .convo-table .convo-action { display: none !important; }
}

/* === 對話監控 LINE 模式（2026-10-24 客戶語音＋LINE 官方帳號後台截圖：「從桌面小圖示點進去就顯示成這樣，
   看得到這位會員是誰，點進去看對話有顏色、有左右，老師會比較願意使用」）===
   預設 LINE 模式；表格模式給主管查舊紀錄。手機（≤768px）不論哪種模式都是上面的 LINE 清單。
   電腦寬螢幕（≥1025px）＝左清單、右對話，點了不換頁；平板只有清單，點了換頁。 */
.convo-view-toggle { display: inline-flex; }
.convo-view-toggle .btn { border-radius: 0; }
.convo-view-toggle .btn:first-child { border-radius: 6px 0 0 6px; }
.convo-view-toggle .btn:last-child { border-radius: 0 6px 6px 0; margin-left: -1px; }
.convo-view-toggle .btn.active { background: #8b6f3e; border-color: #8b6f3e; color: white; }
/* 2026-11-04 客戶語音 _32817205：要「明顯一點點的樣式」，比照 LINE 官方帳號 App 的實心綠底 */
.convo-todo { background: #06a24f; color: #fff; border: 1px solid #06a24f; font-weight: 700; }
/* 2026-11-12 客戶語音 _32923664：問了事情卻沒留姓名手機，系統認不出是誰 */
.convo-await { background: #fff4e0; color: #9a5b00; border: 1px solid #f0c27a; font-weight: 600; }
/* 對話清單用本名搜到「還沒接上 LINE 的會員」時的提示（2026-11-12） */
.convo-unlinked-hint { background: #fff8e6; border: 1px solid #f0d58c; border-radius: 8px; padding: 10px 14px;
    margin-bottom: 12px; font-size: 13px; line-height: 1.7; }
.convo-unlinked-hint a { font-weight: 600; white-space: nowrap; }
.convo-table tr.convo-row.selected,
.convo-table tr.convo-row.selected:hover { background: #f5ecdc; }
.convo-split-pane { display: none; }
@media (max-width: 768px) { .convo-view-toggle { display: none; } }

/* 平板、電腦的 LINE 清單：規則同上面手機版，只是不限螢幕寬度 */
@media (min-width: 769px) {
    .convo-line-mode .convo-mfilter { display: flex; gap: 8px; margin-bottom: 12px; }
    .convo-line-mode .convo-mfilter .form-control { flex: 1; min-width: 0; }
    .convo-line-mode .convo-mfilter .btn { flex-shrink: 0; }
    .convo-line-mode .convo-mfilter .btn.active { background: #f5ecdc; }
    .convo-line-mode .convo-filter:not(.open) { display: none; }
    .convo-line-mode .convo-table thead { display: none; }
    .convo-line-mode .convo-table, .convo-line-mode .convo-table tbody { display: block; }
    .convo-line-mode .convo-table tr.convo-row {
        display: grid;
        grid-template-columns: 48px minmax(0, 1fr) auto;
        grid-template-areas:
            "avatar name    mtime"
            "avatar preview preview"
            "avatar state   state";
        gap: 2px 12px;
        padding: 12px 14px;
        border-bottom: 1px solid var(--border);
    }
    .convo-line-mode .convo-table tr.convo-row:hover { background: #faf6ef; }
    .convo-line-mode .convo-table tr.convo-row:last-child { border-bottom: none; }
    .convo-line-mode .convo-table tr.convo-row td { display: block; padding: 0; border: none; max-width: none !important; }
    .convo-line-mode .convo-table .convo-avatar-cell { display: block; grid-area: avatar; align-self: start; padding-top: 2px; }
    .convo-line-mode .convo-table .convo-name { grid-area: name; font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .convo-line-mode .convo-table .convo-name > div { display: inline; margin-left: 4px; }
    .convo-line-mode .convo-table .convo-mtime { display: block; grid-area: mtime; font-size: 12px; color: var(--text-muted); align-self: center; white-space: nowrap; }
    .convo-line-mode .convo-table tr.convo-row td.convo-preview {
        grid-area: preview; font-weight: normal; color: var(--text-muted); font-size: 13.5px;
        overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere;
    }
    .convo-line-mode .convo-table .convo-state { grid-area: state; text-align: left; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-top: 4px; }
    .convo-line-mode .convo-table .convo-state > div { margin-top: 0 !important; flex-basis: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
    .convo-line-mode .convo-table .convo-mobile-meta { display: inline; font-size: 11px; color: var(--text-muted); }
    .convo-line-mode .convo-table .convo-time,
    .convo-line-mode .convo-table .convo-store,
    .convo-line-mode .convo-table .convo-count,
    .convo-line-mode .convo-table .convo-action { display: none !important; }
}

/* 電腦：左清單（自己捲）＋右對話 */
@media (min-width: 1025px) {
    .convo-line-mode .convo-split { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 16px; align-items: start; }
    .convo-line-mode .convo-split-list {
        background: white; border: 1px solid var(--border); border-radius: 8px;
        height: calc(100vh - 190px); min-height: 420px; overflow-y: auto;
    }
    .convo-line-mode .convo-split-list .table-card { border: none; border-radius: 0; }
    .convo-line-mode .convo-split-list > .empty,
    .convo-line-mode .convo-split-list > .alert { margin: 12px; }
    /* 分頁列在窄清單裡改成兩行置中 */
    .convo-line-mode .convo-split-list > div:last-child:not(.table-card) { justify-content: center; padding: 0 10px 12px; text-align: center; }
    .convo-line-mode .convo-split-pane { display: block; min-width: 0; }
    .convo-split-pane .convo-mhead { display: flex; }
    .convo-split-pane .convo-messages { max-height: calc(100vh - 380px); min-height: 280px; }
    .convo-split-empty {
        height: calc(100vh - 190px); min-height: 420px; border: 1px dashed #d9c6a5; border-radius: 8px;
        display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
        color: var(--text-muted); background: #faf7f1;
    }
}
/* 右半邊不夠寬時，對話資訊／動作排到對話下面，對話本身不要被擠窄。
   後台內容區有最大寬度，看視窗寬度不準，改看右半邊自己的寬度 */
.convo-split-pane { container-type: inline-size; }
@container (max-width: 720px) {
    .convo-split-pane .convo-layout { grid-template-columns: minmax(0, 1fr); gap: 14px; }
}

.alert { padding: 12px 16px; border-radius: 6px; margin-bottom: 16px; }
.alert-success { background: #f0fff4; color: var(--success); border: 1px solid #9ae6b4; }
.alert-error { background: #fff5f5; color: var(--danger); border: 1px solid #fecaca; }

/* === Auth pages（登入 / 改密碼 / 拒絕存取）=== */

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, var(--bg-soft) 0%, #f2e8d9 100%);
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 36px 32px;
    box-shadow: 0 4px 18px rgba(139, 110, 71, 0.08);
}

.auth-brand {
    text-align: center;
    margin-bottom: 28px;
}
.auth-brand .logo {
    width: 56px; height: 56px;
    border-radius: 50%;
    background: var(--brand);
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 22px;
    margin-bottom: 12px;
}
.auth-brand h2 { margin: 0 0 4px; font-size: 20px; }

/* === User badge in sidebar === */

.sidebar-user {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    margin-top: auto;
    font-size: 13px;
}
.sidebar-user .name { font-weight: 500; }
.sidebar-user .meta { color: var(--text-muted); font-size: 11px; margin-top: 2px; }
.sidebar-user form { margin-top: 8px; }
.sidebar-user button {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
}
.sidebar-user button:hover { color: var(--danger); }

/* 版本與手動更新（2026-10-24，參考 PECKER.Web）：側欄最下方，用 /js/app-update.js */
.sidebar-version { padding: 10px 20px 16px; font-size: 12px; color: var(--text-muted); }
.sidebar-version-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.sidebar-version-badge {
    border: none; border-radius: 10px; padding: 2px 8px; cursor: pointer;
    background: #8b6f3e; color: white; font-size: 11px; font-family: inherit;
}
.sidebar-version-actions { display: flex; gap: 6px; margin-top: 6px; }
.sidebar-version-actions button {
    flex: 1; padding: 6px 4px; border: 1px solid var(--border); border-radius: 6px;
    background: white; color: var(--text-main); font-size: 12px; font-family: inherit; cursor: pointer;
}
.sidebar-version-actions button:hover { border-color: var(--brand); }
.sidebar-version-actions button[data-confirm="1"] { background: #fff4e0; border-color: #e0b25a; color: #8a5a00; }
.sidebar-version-status { min-height: 1em; margin-top: 4px; font-size: 11px; }

/* 有新版本提示條：畫面下方浮出，按「立即更新」才重新載入 */
.bm-update-banner {
    position: fixed; left: 16px; right: 16px; bottom: 20px; z-index: 1100;
    max-width: 460px; margin: 0 auto;
    display: flex; align-items: center; gap: 8px;
    background: #3d3226; color: white; border-radius: 12px; padding: 10px 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
}
.bm-update-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.4; }
.bm-update-text b { font-size: 14px; }
.bm-update-text span { font-size: 12px; color: #d9cbb3; }
.bm-update-banner button {
    flex-shrink: 0; border: none; border-radius: 8px; padding: 7px 10px; font-size: 13px; font-family: inherit; cursor: pointer;
    background: transparent; color: #d9cbb3;
}
.bm-update-banner button.primary { background: #b59367; color: white; font-weight: 600; }

/* === 安裝到手機桌面引導（2026-10-24 客戶：還沒安裝的人要有很清楚的圖示引導）=== */
.sidebar-install {
    width: 100%; margin-top: 8px; padding: 8px; border: 1px dashed #b59367; border-radius: 8px;
    background: #fbf6ec; color: #8b6f3e; font-size: 13px; font-weight: 600; font-family: inherit; cursor: pointer;
}
.sidebar-install[hidden] { display: none; }
a.sidebar-install { display: block; box-sizing: border-box; text-align: center; text-decoration: none; }
/* 預約看板第二個桌面圖示（2026-11-26）：data-bm-app 由 /js/pwa-install.js 依網址標在 <html> */
html[data-bm-app="board"] .bm-when-main, html:not([data-bm-app="board"]) .bm-when-board { display: none; }
html[data-bm-app="board"].bm-browser [data-bm-board-help] { display: none; }
.bm-install-card {
    position: fixed; left: 12px; right: 12px; bottom: 16px; z-index: 1050;
    max-width: 460px; margin: 0 auto;
    display: flex; align-items: center; gap: 10px;
    background: white; border: 1px solid #e6dfd3; border-radius: 14px; padding: 10px 12px;
    box-shadow: 0 10px 30px rgba(61, 50, 38, .22);
    animation: bm-install-up .35s ease-out;
}
@keyframes bm-install-up { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.bm-install-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.4; }
.bm-install-text b { font-size: 15px; color: #3d3226; }
.bm-install-text span { font-size: 12.5px; color: var(--text-muted); }
.bm-install-card button, .bm-install-sheet button {
    flex-shrink: 0; border: none; border-radius: 9px; padding: 8px 12px; font-size: 14px; font-family: inherit; cursor: pointer;
}
.bm-install-card .ghost { background: transparent; color: var(--text-muted); padding: 8px 6px; }
.bm-install-card .primary, .bm-install-sheet .primary { background: #8b6f3e; color: white; font-weight: 700; }
.bm-install-sheet { position: fixed; inset: 0; z-index: 1200; }
.bm-install-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .45); }
.bm-install-panel {
    position: absolute; left: 0; right: 0; bottom: 0; max-width: 520px; margin: 0 auto;
    background: white; border-radius: 18px 18px 0 0; padding: 16px 18px calc(20px + env(safe-area-inset-bottom));
    box-shadow: 0 -8px 30px rgba(0, 0, 0, .2); animation: bm-install-up .3s ease-out;
    max-height: 85vh; overflow-y: auto;
}
.bm-install-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.bm-install-head > div { flex: 1; display: flex; flex-direction: column; line-height: 1.4; }
.bm-install-head b { font-size: 17px; color: #3d3226; }
.bm-install-head span { font-size: 13px; color: var(--text-muted); }
.bm-install-head .x { background: transparent; color: var(--text-muted); font-size: 18px; padding: 4px 8px; }
.bm-install-panel .lead { font-size: 14.5px; line-height: 1.7; margin: 4px 0 12px; }
.bm-install-panel .note { font-size: 13px; color: var(--text-muted); margin: 8px 0 0; }
.bm-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.bm-steps li { display: flex; align-items: center; gap: 10px; background: #faf6ef; border-radius: 12px; padding: 10px 12px; font-size: 15px; line-height: 1.5; }
.bm-steps .n { width: 24px; height: 24px; border-radius: 50%; background: #8b6f3e; color: white; font-size: 13px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.bm-steps .ic { width: 34px; height: 34px; border-radius: 9px; background: white; border: 1px solid #e6dfd3; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 18px; color: #3d3226; }
.bm-steps .t { flex: 1; min-width: 0; }
.bm-install-panel .wide { width: 100%; margin-top: 12px; padding: 12px; background: #f3ece0; color: #3d3226; font-weight: 600; }
.bm-install-panel .wide.primary { background: #8b6f3e; color: white; }
.bm-install-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; font-size: 13px; }
.bm-install-foot a { color: #8b6f3e; text-decoration: none; }
.bm-install-foot button { background: transparent; color: var(--text-muted); padding: 6px 0; font-size: 13px; }
/* iPhone Safari 的分享鈕在畫面最下方中間：抽屜上方浮一個跳動箭頭指過去 */
.bm-install-arrow {
    position: fixed; left: 50%; bottom: 6px; transform: translateX(-50%); z-index: 1300; pointer-events: none;
    display: flex; flex-direction: column; align-items: center; color: #0a84ff; font-size: 30px; line-height: 1;
    animation: bm-install-bounce 1s ease-in-out infinite;
}
.bm-install-panel.has-arrow { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
.bm-install-arrow span { font-size: 13px; color: white; background: #0a84ff; border-radius: 10px; padding: 3px 9px; margin-bottom: 2px; text-shadow: none; }
@keyframes bm-install-bounce { 0%, 100% { transform: translate(-50%, 0); } 50% { transform: translate(-50%, 8px); } }

/* === Defaults from template === */
h1:focus { outline: none; }
.valid.modified:not([type=checkbox]) { outline: 1px solid #26b050; }
.invalid { outline: 1px solid var(--danger); }
.validation-message { color: var(--danger); font-size: 13px; margin-top: 4px; }
.blazor-error-boundary { background: var(--danger); color: white; padding: 1rem; }
.blazor-error-boundary::after { content: "發生錯誤，請重新整理頁面。" }

/* === RWD：平板 / 手機（off-canvas 側欄）=== */
.nav-toggle-cb { display: none; }
.mobile-topbar { display: none; }
.nav-overlay { display: none; }
.hamburger {
    display: none;
    background: none; border: none; cursor: pointer;
    font-size: 24px; line-height: 1; padding: 4px 8px; color: var(--text-main);
}

@media (max-width: 1024px) {
    .admin-shell { grid-template-columns: 1fr; }

    .mobile-topbar {
        display: flex; align-items: center; gap: 10px;
        padding: 10px 16px; background: white;
        border-bottom: 1px solid var(--border);
        position: sticky; top: 0; z-index: 90;
    }
    .mobile-topbar .logo {
        width: 30px; height: 30px; border-radius: 50%;
        background: var(--brand); color: white;
        display: inline-flex; align-items: center; justify-content: center;
        font-weight: bold; font-size: 14px;
    }
    .mobile-topbar .title { font-weight: 600; font-size: 15px; }
    .hamburger { display: inline-flex; }

    .sidebar {
        position: fixed; top: 0; left: 0;
        width: 264px; height: 100vh;
        transform: translateX(-100%);
        transition: transform .25s ease;
        z-index: 100;
        box-shadow: 2px 0 18px rgba(0, 0, 0, .14);
    }
    .nav-toggle-cb:checked ~ .sidebar { transform: translateX(0); }
    .nav-toggle-cb:checked ~ .nav-overlay {
        display: block; position: fixed; inset: 0;
        background: rgba(0, 0, 0, .42); z-index: 95;
    }

    .main { padding: 18px; max-width: 100%; }
    .page-header { flex-direction: column; align-items: stretch; }
    .page-header .actions { width: 100%; }
}

@media (max-width: 480px) {
    .main { padding: 12px; }
    .form-card { padding: 16px; }
    .page-header h1 { font-size: 20px; }
}


/* ── PWA 安裝入口（2026-07-24）── */
.pwa-install-btn {
    width: 100%;
    margin-top: 14px;
    padding: 10px 16px;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: transparent;
    color: var(--brand-dark, #8b6e47);
    border: 1px dashed var(--brand, #b59367);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s;
}
.pwa-install-btn:hover { background: rgba(181, 147, 103, 0.08); }

.pwa-ios-hint {
    margin-top: 14px;
    padding: 10px 12px;
    background: rgba(181, 147, 103, 0.08);
    border: 1px solid var(--border, #e5dccb);
    border-radius: 8px;
    font-size: 13px;
    color: var(--text-muted, #8a7f6d);
    line-height: 1.6;
}
.ios-share-glyph { font-size: 15px; color: #0a84ff; }

/* ── 登入頁小螢幕強化（手機）── */
@media (max-width: 480px) {
    .auth-page { padding: 12px; align-items: flex-start; padding-top: 9vh; }
    .auth-card { padding: 26px 20px; border-radius: 14px; }
    /* iOS Safari：input 字級 < 16px 會觸發自動縮放，固定 16px 避免 */
    .auth-card input.form-control,
    .auth-card input[type="email"],
    .auth-card input[type="password"] { font-size: 16px; min-height: 44px; }
    .auth-card .btn { min-height: 46px; font-size: 16px; }
}

/* == 預約看板下半部（候補 + 側欄面板）== */
.board-lower {
    margin-top: 16px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
.board-panel-close { display: none; } /* 桌機面板常駐，不需關閉鈕 */
.board-panel-backdrop { display: none; }

/* 手機：面板改為底部抽屜（bottom sheet），點格子即彈出，不必滾動找表單 */
@media (max-width: 768px) {
    .board-lower { grid-template-columns: 1fr; gap: 14px; }

    .board-table th, .board-table td { padding: 10px 8px; }
    .board-table tbody td:first-child,
    .board-table thead th:first-child { width: 64px; min-width: 64px; }

    .board-panel { display: none; } /* 未開啟時不佔版面 */
    .board-panel.open {
        display: block;
        position: fixed;
        left: 0; right: 0; bottom: 0;
        z-index: 60;
        max-height: 86vh;
        overflow-y: auto;
        margin: 0;
        border-radius: 16px 16px 0 0;
        border-bottom: none;
        box-shadow: 0 -8px 30px rgba(30, 24, 16, 0.22);
        padding-bottom: calc(20px + env(safe-area-inset-bottom));
        animation: bm-sheet-up 0.22s ease-out;
    }
    .board-panel.open::before {
        content: '';
        display: block;
        width: 44px; height: 4px;
        border-radius: 2px;
        background: #d8cdb9;
        margin: 0 auto 12px;
    }
    .board-panel-close {
        display: inline-flex;
        align-items: center; justify-content: center;
        width: 34px; height: 34px;
        border: 1px solid var(--border, #e5dccb);
        border-radius: 50%;
        background: #faf7f1;
        color: var(--text-muted, #8a7f6d);
        font-size: 15px;
        cursor: pointer;
    }
    .board-panel-backdrop {
        display: block;
        position: fixed; inset: 0;
        z-index: 55;
        background: rgba(30, 24, 16, 0.45);
        animation: bm-fade-in 0.2s ease-out;
    }
    /* iOS：輸入框字級小於 16px 會觸發自動縮放 */
    .board-panel input.form-control,
    .board-panel select,
    .board-panel textarea { font-size: 16px; }
    .board-panel .btn { min-height: 44px; }

    @keyframes bm-sheet-up {
        from { transform: translateY(30%); opacity: 0.5; }
        to   { transform: none; opacity: 1; }
    }
    @keyframes bm-fade-in { from { opacity: 0; } to { opacity: 1; } }
}

/* === 對話詳情（2026-10-01：從 LINE 群組按鈕點進來多半是手機，要能直接看、直接回） === */
.convo-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.convo-messages { background: white; border: 1px solid var(--border); border-radius: 8px; padding: 20px; max-height: 72vh; overflow-y: auto; }
.convo-confirm-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 16px; }
.convo-composer { background: white; border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; margin-top: 10px; }
.convo-confirm { background: white; border-radius: 12px; padding: 22px 20px; width: 100%; max-width: 380px; box-shadow: 0 10px 30px rgba(0, 0, 0, .2); }
@media (max-width: 1024px) {
    .convo-layout { grid-template-columns: minmax(0, 1fr); gap: 14px; }
    .convo-messages { padding: 12px; max-height: 55vh; }
    /* 手機上「動作」排在「對話資訊」前面：接手、交還 AI 比看開始時間重要 */
    .convo-layout > aside { display: flex; flex-direction: column; }
    .convo-layout > aside .convo-actions { order: -1; margin-top: 0 !important; margin-bottom: 14px; }
    /* iOS：輸入框字級 < 16px 會自動放大畫面 */
    .convo-reply { font-size: 16px; }
}

/* === 對話泡泡（2026-10-24 客戶語音：要像 LINE 有左右、有顏色區別，老師才願意用）===
   客人靠左白泡泡；店家靠右：AI 淺金、真人深金白字（唯美特金色系，使用者 10/24 選定）；系統通知置中灰 */
.convo-messages { background: #f4efe6; }
.msg { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 14px; }
.msg-body { min-width: 0; max-width: 78%; display: flex; flex-direction: column; align-items: flex-start; }
.msg-meta { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
/* 回覆的同仁姓名（2026-10-24）：深金小標籤，一眼看出是誰回的 */
.msg-staff { margin-left: 4px; color: white; background: #8b6f3e; padding: 1px 7px; border-radius: 8px; font-size: 11.5px; }
.msg-tokens { margin-left: 8px; background: rgba(255, 255, 255, .7); padding: 1px 6px; border-radius: 8px; }
.msg-bubble {
    padding: 9px 14px; border-radius: 18px; white-space: pre-wrap; word-break: break-word;
    line-height: 1.6; max-width: 100%; box-shadow: 0 1px 1px rgba(0, 0, 0, .04);
}
.msg-customer .msg-bubble { background: white; border: 1px solid #e6dfd3; border-top-left-radius: 4px; }
.msg-outbound { flex-direction: row-reverse; }
.msg-outbound .msg-body { align-items: flex-end; }
.msg-outbound .msg-meta { text-align: right; }
.msg-ai .msg-bubble { background: #f3e3c6; color: #3d3226; border-top-right-radius: 4px; }
.msg-human .msg-bubble { background: #8b6f3e; color: white; border-top-right-radius: 4px; }
.msg-human .msg-bubble a { color: white; }
.msg-system { justify-content: center; flex-direction: row; }
.msg-system .msg-avatar { display: none !important; }
.msg-system .msg-body { align-items: center; max-width: 92%; }
.msg-system .msg-bubble { background: #e9e4dc; color: #4a4339; font-size: 13px; border-radius: 12px; box-shadow: none; }
.msg-avatar-pic {
    position: relative; width: 32px; height: 32px; border-radius: 50%; overflow: hidden; flex-shrink: 0;
    background: #e7d6b6; color: #6b5535; font-size: 13px; font-weight: 600;
    display: inline-flex; align-items: center; justify-content: center;
}
.msg-avatar-pic img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

/* 手機頂部會員條（2026-10-24 客戶錄影：「必須移到下面才能知道他是誰」）：固定在網站頂欄下面。
   電腦版 LINE 模式右半邊（.convo-split-pane）也用這條當對話頂部的名字列，所以內部樣式不包在 media 裡 */
.convo-mhead { display: none; }
.convo-mhead {
    align-items: center; gap: 10px;
    background: white; border: 1px solid var(--border); border-radius: 10px;
    padding: 8px 10px; margin-bottom: 10px; box-shadow: 0 2px 8px rgba(0, 0, 0, .06);
}
.convo-mhead .convo-avatar { width: 40px; height: 40px; font-size: 16px; }
.convo-mhead-back { font-size: 30px; line-height: 1; color: var(--text-main); text-decoration: none; padding: 0 4px 4px 0; }
.convo-mhead-who { flex: 1; min-width: 0; }
.convo-mhead-name { font-size: 16px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* 電話一定完整顯示（點了直接撥），門市與狀態太長才截短（2026-11-13 頂部多了「待處理」開關，手機上電話被截成「09810513…」） */
.convo-mhead-sub { display: flex; min-width: 0; font-size: 13px; color: var(--text-muted); white-space: nowrap; }
.convo-mhead-sub > a, .convo-mhead-sub > span:first-child { flex-shrink: 0; }
.convo-mhead-sub > span:last-child:not(:first-child) { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.convo-mhead-sub a { color: #8b6f3e; font-weight: 600; text-decoration: none; }
.convo-mhead-member {
    flex-shrink: 0; font-size: 12px; line-height: 1.3; text-align: center; text-decoration: none;
    color: #8b6f3e; border: 1px solid #d9c6a5; border-radius: 8px; padding: 4px 8px;
}
/* 釘選（2026-10-24 使用者：像 LINE 一樣釘選；聊天室釘選 10-25 起只有自己看得到，訊息釘選仍全店共用）：清單上方的釘選區、對話上方的釘選訊息橫幅 */
.convo-table tr.convo-section td {
    background: #faf6ef; color: #8b6f3e; font-size: 12px; font-weight: 600; padding: 6px 14px;
    border-bottom: 1px solid var(--border);
}
.convo-pin-mark { margin-right: 2px; }
.convo-pin-btn { background: white; cursor: pointer; font-family: inherit; }
.convo-pin-btn.on { background: #f5ecdc; font-weight: 600; }

/* 待處理開關（2026-11-13 客戶語音 _32981102）：沒標＝白底「🔔 待處理」；已標＝跟清單一樣的 LINE 綠「✅ 處理完」 */
.convo-todo-btn { background: white; cursor: pointer; font-family: inherit; }
/* 小手機頂部三顆按鈕＋名字電話擠在一列：按鈕左右留白縮小，讓電話放得下 */
@media (max-width: 480px) {
    .convo-mhead { gap: 6px; padding: 8px 8px; }
    .convo-mhead-member { padding: 4px 5px; }
}
.convo-todo-btn.on { background: #06a24f; border-color: #06a24f; color: #fff; font-weight: 700; }
/* 電腦表格模式頁首的待處理按鈕；手機改放在搜尋框旁邊（.convo-todo-filter） */
@media (max-width: 768px) { .convo-todo-head { display: none; } }

/* 同一位客人的幾段對話之間的分隔線（2026-11-13 客戶語音 _32981157） */
.convo-session-break {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    margin: 6px 0 16px; padding: 6px 0; font-size: 12px; color: #7a6a52;
    border-top: 1px dashed #d9c6a5; border-bottom: 1px dashed #d9c6a5;
}

/* 客人引用的那則（2026-11-13 客戶語音 _32981087）：仿 LINE，泡泡上方灰底一小塊，點了跳到原訊息 */
.msg-quote {
    display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
    max-width: 100%; margin: 0 0 4px; padding: 5px 10px;
    background: #ece7de; border: none; border-left: 3px solid #b59367; border-radius: 8px;
    font-family: inherit; font-size: 12.5px; line-height: 1.5; text-align: left; color: #5c5143; cursor: pointer;
}
.msg-quote:disabled { cursor: default; opacity: 1; }
.msg-quote-who { font-weight: 700; color: #8b6f3e; }
.msg-quote-text { white-space: pre-wrap; word-break: break-word; }
.convo-pinned {
    background: #fffaf0; border: 1px solid #ecd9b4; border-radius: 10px; margin-bottom: 10px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .05); overflow: hidden;
}
.convo-pinned-main, .convo-pinned-item { display: flex; align-items: center; gap: 6px; padding: 6px 8px; }
.convo-pinned-item { border-top: 1px solid #f0e3c8; }
.convo-pinned-text {
    flex: 1; min-width: 0; text-align: left; background: none; border: none; cursor: pointer; padding: 4px;
    font-family: inherit; font-size: 13.5px; color: var(--text-main);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.convo-pinned-item .convo-pinned-text { white-space: normal; overflow-wrap: anywhere; }
.convo-pinned-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.convo-pinned-more {
    flex-shrink: 0; background: white; border: 1px solid #d9c6a5; border-radius: 6px; color: #8b6f3e;
    font-size: 12px; padding: 3px 8px; cursor: pointer; font-family: inherit;
}
.msg-pin-btn {
    background: none; border: none; cursor: pointer; padding: 0 2px; font-size: 12px; opacity: .35;
    font-family: inherit; color: #8b6f3e;
}
.msg-pin-btn:hover, .msg-pin-btn.on { opacity: 1; }
.msg-pin-btn.on { font-weight: 600; }
.msg.msg-pinned .msg-bubble { box-shadow: 0 0 0 2px #e8cf9c; }
@keyframes msg-flash { 0%, 60% { background: #fbeccc; } 100% { background: transparent; } }
.msg.msg-flash { animation: msg-flash 1.6s ease-out; border-radius: 10px; }

/* 點圖放大（2026-10-26）：頭貼與客人傳的照片，見 convo.js 的 bmZoom */
img[data-bm-zoom] { cursor: zoom-in; }
.bm-zoom { position: fixed; inset: 0; z-index: 2000; background: rgba(0, 0, 0, .82); display: flex; align-items: center; justify-content: center; padding: 48px 16px; cursor: zoom-out; }
.bm-zoom img { max-width: min(92vw, 900px); max-height: 82vh; object-fit: contain; border-radius: 8px; box-shadow: 0 8px 30px rgba(0, 0, 0, .5); background: #fff; cursor: default; }
.bm-zoom-close { position: absolute; top: 10px; right: 14px; width: 44px; height: 44px; border: none; border-radius: 50%; background: rgba(255, 255, 255, .15); color: #fff; font-size: 30px; line-height: 1; cursor: pointer; }
.bm-zoom-close:hover { background: rgba(255, 255, 255, .3); }
.bm-zoom-link { position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); color: #fff; font-size: 14px; background: rgba(255, 255, 255, .15); padding: 8px 16px; border-radius: 20px; text-decoration: none; white-space: nowrap; }

/* 名字後備註（2026-10-25）：門市自己寫的短提醒，接在名字後面；跟等級標籤區分用藍灰色 */
.name-note { font-size: 12px; font-weight: 600; color: #3d5a80; background: #e6eef7; border-radius: 4px; padding: 1px 6px; margin-left: 4px; vertical-align: 1px; white-space: nowrap; }
.name-note-edit { border: none; background: none; padding: 0 2px; margin-left: 2px; font-size: 13px; cursor: pointer; opacity: .55; vertical-align: 1px; }
.name-note-edit:hover { opacity: 1; }
.convo-tier { font-size: 11px; font-weight: 600; color: #8b6f3e; background: #f5ecdc; border-radius: 10px; padding: 1px 7px; margin-left: 4px; vertical-align: 2px; }
@media (max-width: 1024px) {
    .convo-page-header { display: none; }
    .convo-mhead { display: flex; position: sticky; top: 51px; z-index: 80; }
}
@media (max-width: 768px) {
    .msg-tokens { display: none; }
    .msg-body { max-width: 84%; }
}

/* === 編輯對話框（2026-10-11 使用者：門市設定按了按鈕，編輯區出現在頁面最下面，以為按鈕沒作用）===
   元件 Components/Shared/EditDialog.razor。桌機、平板＝畫面正中間的視窗；手機（≤768px）＝整個畫面。
   標題與底部按鈕固定，內容太長只捲中間——不管多長都看得到「儲存」。 */
.bm-dialog-backdrop {
    position: fixed; inset: 0; z-index: 1000;
    background: rgba(0, 0, 0, .45);
    display: flex; align-items: center; justify-content: center;
    padding: 24px 16px;
    animation: bm-dialog-fade .15s ease-out;
}
.bm-dialog {
    background: #fff; border-radius: 12px; box-shadow: 0 12px 40px rgba(0, 0, 0, .25);
    width: 100%; max-width: 560px;
    max-height: calc(100vh - 48px); max-height: calc(100dvh - 48px);
    display: flex; flex-direction: column;
}
.bm-dialog-wide { max-width: 760px; }
.bm-dialog-head {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 14px 16px 14px 20px; border-bottom: 1px solid var(--border);
}
.bm-dialog-head h3 { margin: 0; font-size: 17px; line-height: 1.4; }
.bm-dialog-close {
    flex: none; width: 40px; height: 40px; border: 0; border-radius: 8px;
    background: transparent; color: var(--text-muted); font-size: 26px; line-height: 1; cursor: pointer;
}
.bm-dialog-close:hover { background: var(--bg-soft); color: var(--text-main); }
.bm-dialog-body { flex: 1 1 auto; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 16px 20px; }
.bm-dialog-foot {
    display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end;
    padding: 12px 20px; border-top: 1px solid var(--border); background: #fff; border-radius: 0 0 12px 12px;
}
.bm-dialog-foot .bm-dialog-foot-left { margin-right: auto; }
/* 對話框裡的欄位：一格一欄，寬度自動排（桌機三欄、手機一欄），不用每個輸入框寫死寬度 */
.bm-dialog-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 12px; }
.bm-dialog-fields .form-group { margin-bottom: 0; }
.bm-dialog-fields .form-control { width: 100%; }
.bm-dialog-label { display: block; font-size: 13px; font-weight: 600; margin: 0 0 4px; }
.bm-dialog-hint { font-size: 12px; color: var(--text-muted); line-height: 1.7; margin: 4px 0 12px; }
.bm-dialog-note { font-size: 13px; color: var(--text-muted); line-height: 1.7; margin-bottom: 12px; }
/* 對話框開著時背後的頁面不跟著捲 */
body:has(.bm-dialog-backdrop) { overflow: hidden; }
@keyframes bm-dialog-fade { from { opacity: 0; } to { opacity: 1; } }

@media (max-width: 768px) {
    .bm-dialog-backdrop { padding: 0; align-items: stretch; }
    .bm-dialog, .bm-dialog-wide { max-width: none; max-height: none; height: 100vh; height: 100dvh; border-radius: 0; }
    .bm-dialog-head { padding: 10px 8px 10px 16px; }
    .bm-dialog-body { padding: 14px 16px; }
    .bm-dialog-foot { border-radius: 0; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); }
    .bm-dialog-foot .btn { flex: 1 1 auto; min-height: 44px; }
    .bm-dialog-foot .bm-dialog-foot-left { margin-right: 0; flex-basis: 100%; }
    /* iOS：輸入框字級小於 16px 會自動放大整個畫面 */
    .bm-dialog .form-control { font-size: 16px; }
}

/* 存好了的提示（2026-10-11）：對話框關掉後，頁面頂端的提示在手機上常常在畫面外，看不到到底存了沒 */
.bm-toast {
    position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 1100;
    max-width: min(560px, calc(100vw - 32px)); width: max-content;
    background: #1f7a45; color: #fff; border-radius: 10px; padding: 12px 16px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .2); font-size: 14px; line-height: 1.6;
    display: flex; gap: 12px; align-items: flex-start;
    animation: bm-dialog-fade .2s ease-out;
}
.bm-toast button { border: 0; background: transparent; color: #fff; font-size: 20px; line-height: 1; cursor: pointer; padding: 0 2px; }
@media (max-width: 768px) {
    .bm-toast { bottom: calc(16px + env(safe-area-inset-bottom)); width: calc(100vw - 32px); }
}

/* 門市設定（2026-10-11）：說明收合、修改按鈕自動換行 */
.store-help { padding: 0; margin-bottom: 16px; font-size: 13px; color: var(--text-muted); line-height: 1.7; }
.store-help > summary { cursor: pointer; padding: 12px 16px; font-weight: 600; color: var(--text-main); list-style-position: inside; }
.store-help-body { padding: 0 16px 14px; }
.table .store-actions-col { width: 330px; }
.store-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.store-actions .btn { padding: 6px 12px; font-size: 13px; }
/* 平板直拿（769–1024px）也用卡片：表格只剩約 600px，五欄擠成一字一行、按鈕字斷成兩行。
   規則同上面手機的 .m-cards，只套在門市設定這張表 */
@media (min-width: 769px) and (max-width: 1024px) {
    .store-table, .store-table > tbody { display: block; width: 100%; }
    .store-table > thead { display: none; }
    .store-table > tbody > tr { display: block; padding: 12px 16px; border-bottom: 1px solid var(--border); }
    .store-table > tbody > tr:last-child { border-bottom: none; }
    .table.store-table > tbody > tr > td {
        display: block; position: relative; padding: 3px 0 3px 7em; border: none;
        width: auto !important; white-space: normal !important; text-align: left !important;
    }
    .store-table > tbody > tr > td::before {
        content: attr(data-label); position: absolute; left: 0; top: 4px; width: 6.5em;
        font-size: 12px; color: var(--text-muted); line-height: 1.5;
    }
    .table.store-table > tbody > tr > td[data-m] { padding-left: 0; }
    .store-table > tbody > tr > td[data-m]::before { content: none; }
    .store-table > tbody > tr > td[data-m="title"] { font-size: 15px; font-weight: 600; padding-bottom: 6px; }
    .store-table > tbody > tr > td[data-m="actions"] { padding-top: 8px; }
    .store-table .store-actions { justify-content: flex-start; }
    .store-actions .btn { flex: 1 1 calc(33% - 6px); min-height: 42px; }
}
@media (max-width: 768px) {
    .store-actions { justify-content: flex-start !important; }
    .store-actions .btn { flex: 1 1 calc(50% - 6px); white-space: normal; }
}
@media (max-width: 768px) {
    .store-actions .btn { min-height: 42px; }
}

/* 候補通知方式（2026-10-11）：三選一做成可點的大卡片，手機好點 */
.waitlist-modes { display: grid; gap: 8px; }
.waitlist-mode { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; cursor: pointer; font-size: 14px; line-height: 1.6; }
.waitlist-mode input { margin-top: 4px; width: 18px; height: 18px; flex: none; }
.waitlist-mode.is-on { border-color: var(--brand); background: var(--bg-soft); }
.waitlist-mode-desc { display: block; font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* 預約看板「空位待處理」（2026-10-11） */
.wl-release-panel { padding: 14px 16px; margin-bottom: 16px; border-left: 4px solid #d4a24c; }
.wl-release-head { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: baseline; margin-bottom: 10px; }
.wl-release-sub { font-size: 13px; color: var(--text-muted); }
.wl-release-help { font-size: 13px; margin-left: auto; }
.wl-release { border-top: 1px solid var(--border); padding: 12px 0 4px; }
.wl-release:first-of-type { border-top: none; padding-top: 4px; }
.wl-release-title { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; font-size: 14px; }
.wl-release-due { font-size: 13px; color: #a46a10; }
.wl-release-due.is-manual { color: var(--text-muted); }
.wl-release-actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.wl-release-list { display: grid; gap: 6px; margin: 4px 0 8px; }
.wl-release-person { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; justify-content: space-between; background: var(--bg-soft); border-radius: 6px; padding: 8px 10px; font-size: 13px; }
.wl-release-who { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; }
.wl-release-meta { color: var(--text-muted); font-size: 12px; }
@media (max-width: 768px) {
    .wl-release-help { margin-left: 0; }
    .wl-release-actions .btn { flex: 1 1 calc(50% - 6px); min-height: 42px; white-space: normal; }
    .wl-release-person .btn { width: 100%; min-height: 40px; }
}

/* === 貼圖與表情貼（2026-10-22 客戶需求：後台回覆像 LINE 一樣能送貼圖）=== */
.convo-sticker { max-width: 140px; max-height: 140px; display: block; }
.convo-emoji { height: 1.35em; width: auto; vertical-align: -0.3em; margin: 0 1px; }
.convo-emoji-preview { background: #f7f4ee; border: 1px dashed var(--border); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; white-space: pre-wrap; word-break: break-word; }
.convo-picker { border: 1px solid var(--border); border-radius: 10px; margin-top: 10px; background: white; overflow: hidden; min-width: 0; max-width: 100%; }
.convo-picker-head { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.convo-picker-tabs { display: flex; gap: 4px; overflow-x: auto; padding: 6px 8px; border-bottom: 1px solid var(--border); background: var(--bg-soft); }
.convo-picker-tabs button { flex: 0 0 auto; width: 44px; height: 44px; padding: 4px; border: 2px solid transparent; border-radius: 8px; background: none; cursor: pointer; }
.convo-picker-tabs button.on { border-color: var(--brand); background: white; }
.convo-picker-tabs img { width: 100%; height: 100%; object-fit: contain; }
.convo-picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 6px; padding: 8px; max-height: 320px; overflow-y: auto; }
.convo-picker-grid.emoji { grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); }
.convo-picker-grid button { border: none; background: none; padding: 4px; border-radius: 8px; cursor: pointer; aspect-ratio: 1; }
.convo-picker-grid button:hover { background: #f5ede0; }
.convo-picker-grid img { width: 100%; height: 100%; object-fit: contain; }
/* 自訂貼圖（2026-10-22）：上傳格與刪除鈕 */
.convo-picker-tabs button.custom { width: auto; padding: 4px 10px; font-size: 13px; color: var(--brand-dark); font-weight: 600; }
.convo-picker-upload { display: flex; align-items: center; justify-content: center; aspect-ratio: 1; border: 2px dashed var(--border); border-radius: 8px; color: var(--brand-dark); font-size: 13px; cursor: pointer; margin: 0; }
.convo-picker-custom { position: relative; }
.convo-picker-custom > button:first-child { width: 100%; height: 100%; }
.convo-picker-custom .del { position: absolute; top: 0; right: 0; aspect-ratio: auto; width: auto; min-width: 22px; height: 22px; padding: 0 5px; border-radius: 11px; background: var(--danger); color: white; font-size: 12px; line-height: 22px; }
.convo-picker-custom .del.confirm { padding: 0 8px; }

/* === 到訪結果與客人到店紀錄（2026-10-22 客戶語音：臨時沒來設成未到，統計常取消的客人）=== */
.attend-pending { font-size: 10px; color: #b85c00; background: #fff4e6; border: 1px solid #f3cf9e; border-radius: 3px; padding: 0 4px; white-space: nowrap; }
.attend-arrived-btn { font-size: 11px; line-height: 1.4; padding: 1px 8px; border-radius: 10px; border: 1px solid #9cc8a8; background: #e8f5ec; color: #2f6b45; cursor: pointer; white-space: nowrap; }
.attend-arrived-btn:hover { background: #d3ecdb; }
.attend-auto { font-size: 11px; color: #6b6255; background: #efebe4; border-radius: 3px; padding: 0 5px; margin-left: 4px; }
.attend-note { font-size: 12px; color: var(--text-muted); line-height: 1.6; }
.attend-warn { font-size: 12px; color: #9b2c2c; background: #fde8e8; border: 1px solid #f5c2c2; border-radius: 6px; padding: 4px 8px; line-height: 1.6; margin: 2px 0; }
.attend-arrived { font-size: 11px; color: #2f6b45; background: #e8f5ec; border: 1px solid #bfe0c9; border-radius: 3px; padding: 0 5px; white-space: nowrap; }

/* ── 報表頁（2026-10-23）── */
.report-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.report-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); gap: 16px; margin-bottom: 16px; }
.report-card { background: white; border: 1px solid var(--border); border-radius: 8px; padding: 20px; margin-bottom: 16px; min-width: 0; }
.report-grid > .report-card { margin-bottom: 0; }
.report-card h3 { margin: 0 0 12px; font-size: 15px; }
.report-note { font-size: 12px; color: var(--text-muted); margin: 0 0 12px; line-height: 1.7; }
.report-chart { width: 100%; height: 280px; }
.report-hub { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: 12px; margin-bottom: 24px; }
.report-hub a { display: block; background: white; border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; color: var(--text-main); text-decoration: none; transition: border-color .15s, box-shadow .15s; }
.report-hub a:hover { border-color: var(--brand); box-shadow: 0 4px 14px rgba(0,0,0,.06); }
.report-hub .t { font-weight: 600; font-size: 14px; }
.report-hub .d { font-size: 12px; color: var(--text-muted); margin-top: 4px; line-height: 1.5; }
.report-hub .g { grid-column: 1 / -1; font-size: 12px; color: var(--text-muted); margin-top: 4px; letter-spacing: .05em; }
@media (max-width: 768px) { .report-card { padding: 14px; } }

/* === 未讀（2026-10-25 客戶語音＋LINE 官方帳號 App 截圖：未讀的客人時間下面有綠點，桌面圖示顯示幾則未讀）===
   只算需要真人、還沒人點開的對話（AI 回完的不算）；全店共用。綠色沿用 LINE 的 #06c755。 */
.convo-unread-dot {
    display: block; width: 12px; height: 12px; border-radius: 50%;
    background: #06c755; margin: 8px 0 0 auto;
}
/* 表格模式（電腦）：時間欄不顯示，綠點放在名字前 */
.convo-unread-name {
    display: inline-block; width: 9px; height: 9px; border-radius: 50%;
    background: #06c755; margin-right: 6px; vertical-align: middle;
}
.convo-markall { display: inline-flex; align-items: center; }
.convo-table tr.convo-row.unread td.convo-preview { color: var(--text-main); }
.nav-unread {
    margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
    background: #06c755; color: white; font-size: 12px; font-weight: 600; line-height: 20px; text-align: center;
}
.nav-unread[hidden], .topbar-unread[hidden], .convo-unread-dot[hidden] { display: none; }
.hamburger { position: relative; }
.topbar-unread {
    position: absolute; top: 0; right: 0; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
    background: #06c755; color: white; font-size: 10px; font-weight: 600; line-height: 16px; text-align: center;
}
/* LINE 清單（手機、電腦 LINE 模式）：時間欄跨兩列，綠點落在時間下方、最後一句的右邊 */
@media (max-width: 768px) {
    .convo-table tr.convo-row {
        grid-template-areas:
            "avatar name    mtime"
            "avatar preview mtime"
            "avatar state   state";
    }
    .convo-table .convo-mtime { align-self: start; text-align: right; padding-top: 3px !important; }
    .convo-table .convo-unread-name { display: none; }
}
@media (min-width: 769px) {
    .convo-line-mode .convo-table tr.convo-row {
        grid-template-areas:
            "avatar name    mtime"
            "avatar preview mtime"
            "avatar state   state";
    }
    .convo-line-mode .convo-table .convo-mtime { align-self: start; text-align: right; padding-top: 3px !important; }
    .convo-line-mode .convo-table .convo-unread-name { display: none; }
}

/* 數字頁碼列（2026-10-26，Components/Shared/Pager.razor）：對話監控左半邊很窄，一律可換行、置中 */
.bm-pager { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: center; margin-top: 12px; }
.bm-pager .btn { padding: 6px 10px; white-space: nowrap; }
.bm-pager-num { min-width: 38px; justify-content: center; }
.bm-pager-num.active { background: var(--brand); border-color: var(--brand); color: white; font-weight: 600; }
.bm-pager-gap { color: var(--text-muted); padding: 0 2px; }
.bm-pager-jump { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; color: var(--text-muted); margin-left: 6px; }
.bm-pager-jump .form-control { width: 70px; padding: 6px 8px; }
.bm-pager-info { flex-basis: 100%; text-align: center; font-size: 13px; color: var(--text-muted); }
