/* =========================================================================
   UTK_CSHub 後台樣式：淺藍色商務科技風 + iOS 元件
   以 Bootstrap 5 為基礎，覆寫變數並提供 iOS 元件（分段控制、分組清單、開關、聊天泡泡）。
   ========================================================================= */

:root {
    /* iOS 系統色 */
    --ios-blue: #007aff;
    --ios-blue-rgb: 0, 122, 255;
    --ios-blue-dark: #0062cc;
    --ios-cyan: #32ade6;
    --ios-teal: #30b0c7;
    --ios-green: #34c759;
    --ios-orange: #ff9500;
    --ios-red: #ff3b30;
    --ios-gray: #8e8e93;

    /* 文字與底色 */
    --label: #1c1c1e;
    --label-secondary: #6e6e73;
    --label-tertiary: #aeaeb2;
    --separator: rgba(60, 60, 67, .12);
    --fill: rgba(118, 118, 128, .10);
    --fill-strong: rgba(118, 118, 128, .16);
    --surface: #ffffff;
    --bg-top: #e3eefb;
    --bg: #f2f6fb;

    --radius-card: 16px;
    --radius-control: 10px;
    --shadow-card: 0 1px 2px rgba(16, 42, 84, .04), 0 8px 28px rgba(16, 42, 84, .07);
    --shadow-float: 0 12px 40px rgba(16, 42, 84, .14);

    /* Bootstrap 對應 */
    --bs-primary: var(--ios-blue);
    --bs-primary-rgb: var(--ios-blue-rgb);
    --bs-link-color: var(--ios-blue);
    --bs-link-color-rgb: var(--ios-blue-rgb);
    --bs-link-hover-color: var(--ios-blue-dark);
    --bs-body-color: var(--label);
    --bs-body-bg: var(--bg);
    --bs-secondary-color: var(--label-secondary);
    --bs-border-color: var(--separator);
    --bs-border-radius: var(--radius-control);
    --bs-font-sans-serif: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", "Segoe UI", system-ui, sans-serif;
    --bs-font-monospace: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
}

html { font-size: 15px; background-color: var(--bg); }

body {
    color: var(--label);
    background:
        radial-gradient(1200px 380px at 85% -60px, rgba(50, 173, 230, .18), transparent 70%),
        radial-gradient(900px 340px at 0% -80px, rgba(0, 122, 255, .14), transparent 70%),
        linear-gradient(180deg, var(--bg-top) 0, var(--bg) 360px);
    background-attachment: fixed;
    -webkit-font-smoothing: antialiased;
    letter-spacing: .01em;
}

/* 科技感細格線（只在頁面上緣淡淡出現） */
body::before {
    content: "";
    position: fixed;
    inset: 0 0 auto 0;
    height: 360px;
    pointer-events: none;
    z-index: -1;
    background-image:
        linear-gradient(rgba(0, 122, 255, .06) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 122, 255, .06) 1px, transparent 1px);
    background-size: 32px 32px;
    mask-image: linear-gradient(180deg, rgba(0, 0, 0, .9), transparent);
}

a { text-decoration: none; }
.text-secondary { color: var(--label-secondary) !important; }
.small, small { font-size: .86rem; }
::selection { background: rgba(var(--ios-blue-rgb), .2); }

/* ---------- 導覽列（毛玻璃） ---------- */
.app-navbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    background: rgba(255, 255, 255, .72);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: .5px solid var(--separator);
    padding: .55rem 0;
}
.app-navbar .navbar-brand { display: flex; align-items: center; gap: .55rem; color: var(--label); font-weight: 700; }
.brand-mark {
    width: 30px; height: 30px; border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--ios-blue), var(--ios-cyan));
    color: #fff; font-size: .72rem; font-weight: 800; letter-spacing: .02em;
    box-shadow: 0 4px 12px rgba(var(--ios-blue-rgb), .35);
}
.brand-sub { font-size: .78rem; font-weight: 500; color: var(--label-secondary); }
.app-navbar .nav-link {
    color: var(--label);
    font-weight: 500;
    border-radius: 999px;
    padding: .38rem .85rem !important;
    transition: background-color .15s ease, color .15s ease;
}
.app-navbar .nav-link:hover { background: var(--fill); }
.app-navbar .nav-link.active { background: rgba(var(--ios-blue-rgb), .12); color: var(--ios-blue); font-weight: 600; }
.app-navbar .navbar-toggler { border: 0; box-shadow: none; }
.user-chip {
    display: inline-flex; align-items: center; gap: .45rem;
}
.user-avatar {
    width: 28px; height: 28px; border-radius: 50%;
    background: linear-gradient(135deg, #5ac8fa, var(--ios-blue));
    color: #fff; font-size: .78rem; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center;
}

.dropdown-menu {
    border: 0;
    border-radius: 14px;
    padding: .35rem;
    box-shadow: var(--shadow-float);
    background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(20px);
}
.dropdown-item { border-radius: 9px; padding: .5rem .8rem; }
.dropdown-item:active { background: var(--ios-blue); }

/* ---------- 標題 ---------- */
.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .75rem; margin-bottom: 1.25rem; }
.large-title { font-size: 1.95rem; font-weight: 700; letter-spacing: -.02em; margin: 0; line-height: 1.2; }
.page-subtitle { color: var(--label-secondary); margin: .3rem 0 0; }
.section-label { font-size: .82rem; color: var(--label-secondary); margin: 0 0 .45rem .9rem; font-weight: 500; }
.section-footer { font-size: .8rem; color: var(--label-secondary); margin: .45rem .9rem 0; }
.breadcrumb { --bs-breadcrumb-divider: "›"; font-size: .86rem; margin-bottom: .6rem; }
.breadcrumb-item a { color: var(--ios-blue); }

/* ---------- 卡片 ---------- */
.card {
    border: 0;
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    background: var(--surface);
}
.card-body { padding: 1.25rem 1.35rem; }
.card-title-sm { font-size: 1rem; font-weight: 600; margin-bottom: .9rem; }
.card-danger { box-shadow: var(--shadow-card), inset 0 0 0 1px rgba(255, 59, 48, .18); }

/* ---------- 專案清單 ---------- */
.project-card { transition: transform .18s ease, box-shadow .18s ease; color: inherit; scroll-margin-top: 5rem; }
/* 同一列卡片等高：角色／最近對話與快捷按鈕貼齊卡片底部 */
.project-card > .card-body { display: flex; flex-direction: column; }
.project-card .project-meta { margin-top: auto; }
.project-stats, .project-readiness, .project-note { margin-bottom: .9rem; }
.project-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-float); }
.project-icon {
    position: relative;
    width: 44px; height: 44px; border-radius: 12px; flex: none;
    display: inline-flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700; font-size: 1.1rem;
    background: var(--project-color, linear-gradient(135deg, var(--ios-blue), var(--ios-cyan)));
}
.project-icon-muted { background: var(--fill-strong); }
.project-dot {
    position: absolute; top: -4px; right: -4px; width: 13px; height: 13px; border-radius: 50%;
    background: var(--ios-red); border: 2px solid var(--surface);
}
.project-head { display: flex; align-items: center; gap: .85rem; }
.project-name { font-size: 1rem; font-weight: 600; margin: 0; line-height: 1.35; }
.project-name a { color: inherit; text-decoration: none; }
/* 整張卡片可點（stretched-link），鍵盤焦點框畫在整張卡片上 */
.project-card .stretched-link:focus-visible { outline: none; }
.project-card .stretched-link:focus-visible::after { outline: 3px solid rgba(var(--ios-blue-rgb), .55); outline-offset: 2px; border-radius: var(--radius-card); }
.project-slug { font-family: var(--bs-font-monospace); font-size: .8rem; color: var(--label-secondary); }
.project-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .9rem; padding-top: .75rem; border-top: .5px solid var(--separator); font-size: .82rem; color: var(--label-secondary); min-width: 0; }
.project-role { padding: .05rem .5rem; border-radius: 6px; background: var(--fill); font-size: .76rem; font-weight: 500; flex: none; }
.project-role.is-admin-view { background: transparent; box-shadow: inset 0 0 0 1px var(--label-tertiary); }
/* 卡片內可點的元素要蓋在 stretched-link 上面 */
.project-stats, .project-actions, .project-action-link { position: relative; z-index: 2; }
.project-stats { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .9rem; }
.stat-chip {
    display: inline-flex; align-items: center; gap: .3rem; padding: .22rem .65rem; border-radius: 999px;
    font-size: .8rem; font-weight: 500; text-decoration: none;
    background: rgba(var(--ios-blue-rgb), .09); color: var(--ios-blue);
}
.stat-chip b { font-weight: 700; }
.stat-chip:hover { filter: brightness(.94); }
.stat-chip.is-alert { background: rgba(255, 59, 48, .12); color: #d70015; }
.stat-chip.is-warn { background: rgba(255, 149, 0, .15); color: #b86600; }
.stat-chip.is-plain { background: var(--fill); color: var(--label-secondary); }
.project-readiness { margin-top: .9rem; }
.project-readiness .progress { height: 6px; background: var(--fill-strong); border-radius: 3px; }
.project-readiness .progress-bar { background: var(--ios-blue); border-radius: 3px; }
.project-action-link { font-weight: 600; text-decoration: none; }
.project-note { margin-top: .9rem; font-size: .84rem; color: var(--label-secondary); }
.project-actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .75rem; }
.project-actions .btn {
    --bs-btn-padding-y: .22rem; --bs-btn-padding-x: .65rem; --bs-btn-font-size: .8rem; --bs-btn-font-weight: 500;
    --bs-btn-bg: var(--fill); --bs-btn-border-color: transparent; --bs-btn-color: var(--label);
    --bs-btn-hover-bg: var(--fill-strong); --bs-btn-hover-border-color: transparent; --bs-btn-hover-color: var(--label);
}
/* 停用、已刪除：頭像改灰（不用 filter，否則紅點也會變灰；inline 的 --project-color 要用 !important 蓋過） */
.project-card.is-disabled .project-icon, .project-card.is-deleted .project-icon { background: #c7c7cc !important; }
.project-card.is-disabled .project-name, .project-card.is-deleted .project-name { color: var(--label-secondary); }
.project-card.is-deleted .project-meta { margin-top: .9rem; }
.project-card.is-deleted:hover { transform: none; box-shadow: var(--shadow-card); }
.project-card.row-highlight { animation: project-highlight 2.6s ease-out; background: var(--surface); border-radius: var(--radius-card); }
@keyframes project-highlight { 0%, 45% { box-shadow: 0 0 0 3px rgba(var(--ios-blue-rgb), .45), var(--shadow-card); } 100% { box-shadow: var(--shadow-card); } }
.project-attention-summary { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.attention-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ios-red); flex: none; }
.project-filter .form-switch { min-height: 0; }
@media (prefers-reduced-motion: reduce) {
    .project-card, .project-card:hover { transition: none; transform: none; }
    .project-card.row-highlight { animation: none; box-shadow: 0 0 0 3px rgba(var(--ios-blue-rgb), .35), var(--shadow-card); }
}
/* 手機：卡片改成 iOS 分組清單，一個畫面看得到更多專案；快捷按鈕收起（專案總覽都有） */
@media (max-width: 575.98px) {
    .project-grid {
        --bs-gutter-x: 0; --bs-gutter-y: 0;
        background: var(--surface); border-radius: var(--radius-card); box-shadow: var(--shadow-card); overflow: hidden;
    }
    .project-grid .project-card { border-radius: 0; box-shadow: none; background: transparent; }
    .project-grid > div + div .project-card { border-top: .5px solid var(--separator); }
    .project-card:hover, .project-card.is-deleted:hover { transform: none; box-shadow: none; }
    .project-card .card-body { padding: .85rem 1rem; }
    .project-card .project-icon { width: 40px; height: 40px; font-size: 1rem; }
    .project-actions { display: none; }
    .project-card.is-deleted form { margin-top: .6rem !important; }
    .project-meta { margin-top: .55rem; padding-top: 0; border-top: 0; }
    .project-stats, .project-readiness, .project-note { margin-top: .6rem; margin-bottom: 0; }
    .project-card.row-highlight { animation: row-highlight 2.6s ease-out; box-shadow: none; border-radius: 0; }
    .project-card .stretched-link:focus-visible::after { outline-offset: -3px; border-radius: 0; }
}

.stat-tile .stat-value { font-size: 1.55rem; font-weight: 700; letter-spacing: -.02em; }
.stat-tile .stat-label { font-size: .82rem; color: var(--label-secondary); }

.empty-state {
    background: rgba(255, 255, 255, .7);
    border: 1.5px dashed rgba(var(--ios-blue-rgb), .25);
    border-radius: var(--radius-card);
}

/* ---------- iOS 分組清單 ---------- */
.ios-list { list-style: none; margin: 0; padding: 0; }
.ios-list > li, .ios-row {
    display: flex; align-items: center; gap: .75rem;
    min-height: 48px;
    padding: .7rem 1.1rem;
    position: relative;
}
.ios-list > li + li::before, .ios-row + .ios-row::before {
    content: ""; position: absolute; top: 0; left: 1.1rem; right: 0;
    border-top: .5px solid var(--separator);
}
.ios-row-title { flex: 1; min-width: 0; }
.ios-row-detail { color: var(--label-secondary); font-size: .9rem; }
.ios-chevron::after { content: "›"; color: var(--label-tertiary); font-size: 1.3rem; line-height: 1; margin-left: .25rem; }

/* ---------- 帳號管理 ---------- */
.user-row { scroll-margin-top: 5rem; }
.user-row .user-avatar { width: 36px; height: 36px; font-size: .9rem; flex: none; }
.user-name { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .4rem; }
.user-row.is-inactive .user-avatar { filter: grayscale(1); opacity: .5; }
.user-row.is-inactive .user-name > .fw-semibold { color: var(--label-secondary); }
.row-highlight { animation: row-highlight 2.6s ease-out; border-radius: 12px; }
@keyframes row-highlight { 0%, 45% { background: rgba(var(--ios-blue-rgb), .12); } 100% { background: transparent; } }
@media (prefers-reduced-motion: reduce) { .row-highlight { animation: none; background: rgba(var(--ios-blue-rgb), .08); } }
.user-filter { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.user-filter-keyword { flex: 1 1 14rem; max-width: 22rem; }
/* .ios-segmented span 會套用分段按鈕的樣式，這裡要蓋回去 */
.ios-segmented .seg-count { padding: 0; border-radius: 0; font-size: .78rem; color: var(--label-secondary); font-weight: 500; margin-left: .15rem; }
.user-meta { display: flex; min-width: 0; }
.user-meta > span { flex: none; }
.user-meta > .text-truncate { flex: 0 1 auto; min-width: 0; }
@media (max-width: 575.98px) {
    /* 手機：Email 與最後登入分兩行；搜尋框獨佔一行，兩個下拉並排 */
    .user-meta { flex-direction: column; }
    .user-meta-sep { display: none; }
    .user-filter-keyword { flex-basis: 100%; max-width: none; }
    .user-filter > .select2-container { flex: 1 1 0; width: auto !important; min-width: 0; }
}

/* ---------- 表格（iOS 清單風格） ---------- */
.table { --bs-table-bg: transparent; margin: 0; }
.table > :not(caption) > * > * { padding: .75rem 1.1rem; border-bottom-color: var(--separator); }
.table thead th {
    font-size: .78rem; font-weight: 600; color: var(--label-secondary);
    background: rgba(242, 246, 251, .7) !important;
    border-bottom: .5px solid var(--separator);
    white-space: nowrap;
}
.table tbody tr:last-child > * { border-bottom: 0; }
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: rgba(var(--ios-blue-rgb), .04); }

/* ---------- 分段控制（Segmented Control） ---------- */
.ios-segmented {
    display: inline-flex;
    gap: 2px;
    padding: 3px;
    border-radius: 11px;
    background: var(--fill-strong);
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
}
.ios-segmented::-webkit-scrollbar { display: none; }
.ios-segmented a, .ios-segmented button, .ios-segmented span {
    flex: none;
    border: 0;
    background: transparent;
    color: var(--label);
    font-size: .9rem;
    font-weight: 500;
    padding: .4rem 1rem;
    border-radius: 8px;
    white-space: nowrap;
    transition: background-color .15s ease, box-shadow .15s ease;
}
.ios-segmented a:hover { color: var(--label); background: rgba(255, 255, 255, .5); }
.ios-segmented .active {
    background: #fff;
    font-weight: 600;
    box-shadow: 0 3px 8px rgba(0, 0, 0, .12), 0 1px 1px rgba(0, 0, 0, .04);
}
.ios-segmented .disabled { color: var(--label-tertiary); cursor: default; }

/* ---------- 按鈕 ---------- */
.btn {
    --bs-btn-border-radius: var(--radius-control);
    --bs-btn-font-weight: 600;
    --bs-btn-padding-x: 1.05rem;
    --bs-btn-padding-y: .5rem;
    transition: transform .08s ease, background-color .15s ease, opacity .15s ease;
}
.btn:active { transform: scale(.97); }
.btn-sm { --bs-btn-border-radius: 8px; --bs-btn-padding-x: .75rem; --bs-btn-padding-y: .3rem; --bs-btn-font-size: .84rem; }
.btn-primary {
    --bs-btn-bg: var(--ios-blue); --bs-btn-border-color: var(--ios-blue);
    --bs-btn-hover-bg: var(--ios-blue-dark); --bs-btn-hover-border-color: var(--ios-blue-dark);
    --bs-btn-active-bg: var(--ios-blue-dark); --bs-btn-active-border-color: var(--ios-blue-dark);
    --bs-btn-disabled-bg: var(--ios-blue); --bs-btn-disabled-border-color: var(--ios-blue);
    box-shadow: 0 4px 14px rgba(var(--ios-blue-rgb), .28);
}
.btn-success { --bs-btn-bg: var(--ios-green); --bs-btn-border-color: var(--ios-green); --bs-btn-hover-bg: #2db14f; --bs-btn-hover-border-color: #2db14f; }

/* iOS tinted（淡色底）按鈕取代外框按鈕 */
.btn-outline-primary, .btn-outline-secondary, .btn-outline-danger, .btn-outline-success {
    --bs-btn-border-color: transparent;
    --bs-btn-hover-border-color: transparent;
    --bs-btn-active-border-color: transparent;
}
.btn-outline-primary { --bs-btn-color: var(--ios-blue); --bs-btn-bg: rgba(var(--ios-blue-rgb), .10); --bs-btn-hover-bg: rgba(var(--ios-blue-rgb), .18); --bs-btn-hover-color: var(--ios-blue); --bs-btn-active-bg: rgba(var(--ios-blue-rgb), .24); --bs-btn-active-color: var(--ios-blue); }
.btn-outline-secondary { --bs-btn-color: var(--label); --bs-btn-bg: var(--fill); --bs-btn-hover-bg: var(--fill-strong); --bs-btn-hover-color: var(--label); --bs-btn-active-bg: rgba(118, 118, 128, .24); --bs-btn-active-color: var(--label); }
.btn-outline-danger { --bs-btn-color: var(--ios-red); --bs-btn-bg: rgba(255, 59, 48, .10); --bs-btn-hover-bg: rgba(255, 59, 48, .18); --bs-btn-hover-color: var(--ios-red); --bs-btn-active-bg: rgba(255, 59, 48, .24); --bs-btn-active-color: var(--ios-red); }
.btn-outline-success { --bs-btn-color: #248a3d; --bs-btn-bg: rgba(52, 199, 89, .12); --bs-btn-hover-bg: rgba(52, 199, 89, .2); --bs-btn-hover-color: #248a3d; --bs-btn-active-bg: rgba(52, 199, 89, .26); --bs-btn-active-color: #248a3d; }
.btn-link { --bs-btn-color: var(--ios-blue); font-weight: 500; }

/* ---------- 表單 ---------- */
.form-label { font-size: .86rem; font-weight: 500; color: var(--label-secondary); margin-bottom: .35rem; }
.form-control, .form-select {
    background-color: var(--fill);
    border: 1px solid transparent;
    border-radius: var(--radius-control);
    padding: .55rem .8rem;
    transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.form-control:focus, .form-select:focus {
    background-color: #fff;
    border-color: var(--ios-blue);
    box-shadow: 0 0 0 4px rgba(var(--ios-blue-rgb), .15);
}
.form-control:disabled, .form-control[readonly] { background-color: rgba(118, 118, 128, .07); }
.form-control-color { padding: .3rem; width: 3rem; }
.form-text { color: var(--label-secondary); font-size: .8rem; }
.input-group > .form-control:not(:last-child) { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-group .btn { box-shadow: none; }
.form-narrow { max-width: 40rem; }

/* iOS 開關 */
.form-switch { padding-left: 3.4em; min-height: 1.9em; display: flex; align-items: center; }
.form-switch .form-check-input {
    width: 2.85em; height: 1.72em;
    margin-left: -3.4em; margin-top: 0;
    border: 0;
    background-color: rgba(120, 120, 128, .2);
    --bs-form-switch-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3.35' fill='%23fff'/%3e%3c/svg%3e");
    box-shadow: none;
    transition: background-color .2s ease, background-position .2s ease;
    cursor: pointer;
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .06));
}
.form-switch .form-check-input:focus { --bs-form-switch-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3.35' fill='%23fff'/%3e%3c/svg%3e"); box-shadow: 0 0 0 4px rgba(var(--ios-blue-rgb), .15); }
.form-switch .form-check-input:checked { background-color: var(--ios-green); }
.form-switch .form-check-label { cursor: pointer; }
.form-check-input:checked { background-color: var(--ios-blue); border-color: var(--ios-blue); }

/* ---------- 標籤、提示 ---------- */
.badge { font-weight: 600; border-radius: 999px; padding: .35em .7em; letter-spacing: .01em; }
.badge-soft-success { background: rgba(52, 199, 89, .14); color: #248a3d; }
.badge-soft-warning { background: rgba(255, 149, 0, .14); color: #c26d00; }
.badge-soft-danger { background: rgba(255, 59, 48, .12); color: #d70015; }
.badge-soft-secondary { background: var(--fill-strong); color: var(--label-secondary); }
.badge-soft-primary { background: rgba(var(--ios-blue-rgb), .12); color: var(--ios-blue); }
.badge-soft-info { background: rgba(50, 173, 230, .15); color: #0a7aa8; }

.alert { border: 0; border-radius: 14px; padding: .85rem 1.1rem; }
.alert-success { background: rgba(52, 199, 89, .14); color: #1e6f33; }
.alert-danger { background: rgba(255, 59, 48, .11); color: #b0140a; }
.alert-warning { background: rgba(255, 149, 0, .14); color: #8a4f00; }
.alert-info { background: rgba(var(--ios-blue-rgb), .1); color: #0a4a99; }

.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.status-dot.green { background: var(--ios-green); }
.status-dot.orange { background: var(--ios-orange); }
.status-dot.red { background: var(--ios-red); }
.status-dot.gray { background: var(--ios-gray); }
.status-dot.blue { background: var(--ios-blue); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

.ios-progress { height: 8px; border-radius: 999px; background: var(--fill-strong); overflow: hidden; }
.ios-progress > div { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--ios-blue), var(--ios-cyan)); transition: width .3s ease; }
.ios-progress.over > div { background: var(--ios-orange); }

.checklist li { padding: .5rem 0 .5rem 2rem; position: relative; }
.checklist li::before {
    position: absolute; left: 0; top: .5rem;
    width: 1.35rem; height: 1.35rem; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: .75rem; font-weight: 700;
}
.checklist li.done::before { content: "✓"; background: var(--ios-green); color: #fff; }
.checklist li.todo { color: var(--label-secondary); }
.checklist li.todo::before { content: ""; border: 1.5px solid var(--label-tertiary); }

.code-box {
    font-family: var(--bs-font-monospace);
    font-size: .82rem;
    background: #0f1b2d;
    color: #d6e6ff;
    border-radius: 12px;
    padding: .9rem 1rem;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 32rem;
    overflow: auto;
}

.code-box code { color: inherit; font-size: inherit; }
.text-pre-line { white-space: pre-line; }
.min-w-0 { min-width: 0; }
.stat-tile { color: inherit; }
.audit-changes { max-width: 28rem; }
.pagination { --bs-pagination-border-radius: 8px; --bs-pagination-active-bg: var(--ios-blue); --bs-pagination-active-border-color: var(--ios-blue); }

.sticky-actions {
    position: sticky;
    bottom: 0;
    padding: .9rem 0;
    background: linear-gradient(to top, var(--bg) 65%, transparent);
    z-index: 5;
}

/* ---------- 上傳區 ---------- */
.drop-zone {
    border: 1.5px dashed rgba(var(--ios-blue-rgb), .35);
    border-radius: 14px;
    background: rgba(var(--ios-blue-rgb), .04);
    padding: 1.4rem;
    text-align: center;
    transition: background-color .15s ease, border-color .15s ease;
    cursor: pointer;
}
.drop-zone.dragover { background: rgba(var(--ios-blue-rgb), .1); border-color: var(--ios-blue); }
.drop-zone input[type=file] { display: none; }

/* ---------- 試用對話（iMessage 風格） ---------- */
.chat-window { display: flex; flex-direction: column; height: min(70vh, 640px); }
.chat-thread { flex: 1; overflow-y: auto; padding: 1.1rem; display: flex; flex-direction: column; gap: .3rem; }
.chat-row { display: flex; flex-direction: column; max-width: 82%; }
.chat-row.user { align-self: flex-end; align-items: flex-end; }
.chat-row.ai { align-self: flex-start; align-items: flex-start; }
.bubble {
    padding: .55rem .9rem;
    border-radius: 19px;
    line-height: 1.5;
    word-break: break-word;
    white-space: pre-wrap;
}
.chat-row.user .bubble { background: linear-gradient(180deg, #1a8cff, var(--ios-blue)); color: #fff; border-bottom-right-radius: 6px; }
.chat-row.ai .bubble { background: #e9e9eb; color: var(--label); border-bottom-left-radius: 6px; }
.chat-row.ai .bubble.related { background: rgba(255, 149, 0, .14); }
.chat-row.ai .bubble.unrelated { background: var(--fill-strong); color: var(--label-secondary); }
.chat-row.ai .bubble.error { background: rgba(255, 59, 48, .1); color: #b0140a; }
.bubble.md { white-space: normal; }
.bubble.md > :last-child { margin-bottom: 0; }
.bubble.md p { margin: 0 0 .5em; }
.bubble.md ul, .bubble.md ol { margin: 0 0 .5em; padding-left: 1.25em; }
.bubble.md li { margin: .1em 0; }
.bubble.md h1, .bubble.md h2, .bubble.md h3, .bubble.md h4 { font-size: 1rem; font-weight: 700; margin: .4em 0 .3em; }
.bubble.md code { background: rgba(0, 0, 0, .06); color: inherit; border-radius: 5px; padding: .05em .35em; font-size: .88em; }
.bubble.md table { border-collapse: collapse; margin: .3em 0 .6em; font-size: .9em; background: #fff; border-radius: 8px; overflow: hidden; }
.bubble.md th, .bubble.md td { border: .5px solid var(--separator); padding: .3em .6em; }
.bubble.md th { background: rgba(var(--ios-blue-rgb), .06); }
.bubble.md a { color: var(--ios-blue); text-decoration: underline; }
.bubble.md blockquote { border-left: 3px solid var(--label-tertiary); padding-left: .7em; color: var(--label-secondary); margin: 0 0 .5em; }
.chat-meta { font-size: .74rem; color: var(--label-secondary); margin: .2rem .55rem .55rem; display: flex; flex-wrap: wrap; gap: .25rem .6rem; align-items: center; }
.chat-actions { display: flex; gap: .4rem; margin: .1rem 0 .5rem; }
.chat-actions .btn { border-radius: 999px; }
.chat-composer {
    display: flex; gap: .5rem; align-items: flex-end;
    padding: .7rem .8rem;
    border-top: .5px solid var(--separator);
    background: rgba(248, 250, 253, .9);
    border-radius: 0 0 var(--radius-card) var(--radius-card);
}
.chat-composer textarea {
    resize: none; border-radius: 20px; padding: .5rem 1rem; max-height: 8rem;
    background: #fff; border: 1px solid var(--separator);
}
.chat-send {
    width: 2.25rem; height: 2.25rem; border-radius: 50%; padding: 0; flex: none;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 1.1rem; box-shadow: none;
}
.typing { display: inline-flex; gap: 4px; padding: .75rem .95rem; background: #e9e9eb; border-radius: 19px; border-bottom-left-radius: 6px; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: #9a9aa0; animation: typing 1.2s infinite ease-in-out; }
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }
@keyframes typing { 0%, 60%, 100% { transform: translateY(0); opacity: .45; } 30% { transform: translateY(-4px); opacity: 1; } }
.chat-suggestions { display: flex; flex-wrap: wrap; gap: .4rem; padding: 0 1.1rem .6rem; }
.chat-suggestions button {
    border: 1px solid rgba(var(--ios-blue-rgb), .3); background: #fff; color: var(--ios-blue);
    border-radius: 999px; padding: .3rem .8rem; font-size: .84rem;
}

.result-pass { color: #248a3d; font-weight: 600; }
.result-fail { color: #d70015; font-weight: 600; }

/* ---------- 工作台 ---------- */
/* 版面：電腦與平板滿版、整頁固定高度（只有清單、訊息串、對話資訊會捲動）；手機見下方「工作台（手機）」 */
.wb-grid { display: grid; grid-template-columns: 300px minmax(0, 1fr) 280px; gap: 1rem; height: 520px; }
@media (min-width: 1400px) { .wb-grid { grid-template-columns: 340px minmax(0, 1fr) 320px; } }
/* 還沒選對話（沒有對話資訊）時，中間欄延伸到右欄 */
@media (min-width: 1200px) { .wb-grid:has(> .wb-info[hidden]) > .wb-chat { grid-column: span 2; } }
@media (min-width: 768px) {
    body.wb-page .container-xl { max-width: none; padding-left: 1.25rem; padding-right: 1.25rem; }
    .wb-top { margin-bottom: .75rem !important; }
    .wb-top .large-title { font-size: 1.4rem; }
}
@media (min-width: 768px) and (min-height: 560px) {
    body.wb-page { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
    body.wb-page > header { flex-shrink: 0; }
    body.wb-page > main { flex: 1; min-height: 0; display: flex; flex-direction: column; padding-top: .9rem !important; padding-bottom: 1rem !important; }
    .wb { flex: 1; min-height: 0; display: flex; flex-direction: column; }
    .wb-grid { flex: 1; min-height: 0; height: auto; }
}
.wb-list, .wb-chat, .wb-info { min-height: 0; overflow: hidden; }
.wb-top-title { display: flex; align-items: baseline; gap: .75rem; }
.wb-conn { display: inline-flex; align-items: center; gap: .35rem; }
.wb-conn-dot { width: .5rem; height: .5rem; border-radius: 50%; background: var(--label-tertiary); flex-shrink: 0; }
.wb-conn-dot.ok { background: var(--ios-green); }
.wb-conn-dot.bad { background: var(--ios-red); }
.wb-banner {
    display: flex; align-items: center; flex-wrap: wrap; gap: .3rem .75rem; margin-bottom: .75rem; padding: .5rem .9rem;
    border-radius: 12px; background: #d70015; color: #fff; font-size: .88rem; font-weight: 600;
}
.wb-banner[hidden] { display: none; }
.wb-banner-sub { font-weight: 400; opacity: .9; }
.wb-kbd {
    display: inline-block; min-width: 1.5em; padding: 0 .35rem; border: 1px solid var(--separator); border-bottom-width: 2px; border-radius: 6px;
    background: var(--surface); color: var(--label-secondary); font-size: .72rem; line-height: 1.45; text-align: center; font-weight: 500;
}
.dropdown-item .wb-kbd { float: right; margin-left: 1rem; }

/* 清單 */
.wb-list { display: flex; flex-direction: column; }
.wb-tabs { display: flex; align-items: center; gap: .25rem; padding: .6rem .6rem .4rem; }
.wb-tabs button {
    border: none; background: transparent; border-radius: 8px; padding: .3rem .6rem; font-size: .82rem;
    color: var(--label-secondary); font-weight: 600; white-space: nowrap;
}
.wb-tabs button.active { background: rgba(var(--ios-blue-rgb), .12); color: var(--ios-blue); }
@media (hover: hover) { .wb-tabs button:not(.active):hover { background: var(--fill); } }
.wb-more { margin-left: auto; }
.wb-tabs .wb-more-btn::after {
    content: ""; display: inline-block; width: .38rem; height: .38rem; margin: 0 0 .18rem .4rem;
    border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg);
}
@media (min-width: 768px) { .wb-tab-more { display: none; } }
.wb-count:not(:empty) { display: inline-block; min-width: 1.2rem; padding: 0 .3rem; border-radius: 999px; background: var(--ios-red); color: #fff; font-size: .7rem; line-height: 1.2rem; text-align: center; }
.wb-count.muted:not(:empty) { background: var(--fill-strong); color: var(--label-secondary); }
.wb-unread-dot { display: inline-block; width: .45rem; height: .45rem; margin-left: .2rem; border-radius: 50%; background: var(--ios-red); vertical-align: top; }
.wb-unread-dot[hidden] { display: none; }
.wb-filter { display: grid; gap: .4rem; padding: 0 .6rem .6rem; border-bottom: .5px solid var(--separator); }
.wb-search { position: relative; }
.wb-search input { padding-right: 3.6rem; }
.wb-search-kbd { position: absolute; right: .5rem; top: 50%; transform: translateY(-50%); pointer-events: none; }
.wb-search input:focus + .wb-search-kbd, .wb-search input:not(:placeholder-shown) + .wb-search-kbd { display: none !important; }
.wb-items { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.wb-item { padding: .65rem .9rem; border-bottom: .5px solid var(--separator); cursor: pointer; }
@media (hover: hover) { .wb-item:hover { background: var(--fill); } }
.wb-item:focus { outline: none; }
.wb-item:focus-visible { box-shadow: inset 0 0 0 2px var(--ios-blue); }
.wb-item.active { background: rgba(var(--ios-blue-rgb), .09); box-shadow: inset 3px 0 0 var(--ios-blue); }
.wb-item.urgent { box-shadow: inset 3px 0 0 var(--ios-red); }
.wb-item.urgent.active { box-shadow: inset 3px 0 0 var(--ios-red); }
.wb-dot { display: inline-block; width: .5rem; height: .5rem; margin: 0 .4rem .1rem 0; border-radius: 50%; background: var(--ios-blue); vertical-align: middle; }
.wb-wait { flex-shrink: 0; padding: .05rem .5rem; border-radius: 999px; background: var(--fill); color: var(--label-secondary); font-size: .74rem; font-weight: 600; white-space: nowrap; }
.wb-wait.warn { background: rgba(255, 149, 0, .15); color: #b25000; }
.wb-wait.danger { background: rgba(255, 59, 48, .13); color: #d70015; }
.wb-none { padding: 2rem 1rem; text-align: center; color: var(--label-secondary); font-size: .9rem; }

/* 對話 */
.wb-chat { display: flex; flex-direction: column; }
.wb-empty { margin: auto; color: var(--label-secondary); }
.wb-home { width: min(36rem, 90vw); color: var(--label); padding: 1rem; }
.wb-home .section-label { margin-left: 0; }
.wb-stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .6rem; }
@media (max-width: 991.98px) { .wb-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.wb-stat { padding: .8rem .9rem; border-radius: 14px; background: var(--fill); }
.wb-stat-num { font-size: 1.5rem; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.wb-stat-label { font-size: .78rem; color: var(--label-secondary); }
.wb-chat-inner { position: relative; display: flex; flex-direction: column; height: 100%; min-height: 0; }
.wb-chat-inner[hidden] { display: none; }
.wb-chat-inner.loading .wb-thread, .wb-chat-inner.loading .wb-ext { opacity: .4; transition: opacity .15s; }
.wb-chat-header { display: flex; gap: .75rem; align-items: center; padding: .75rem 1rem; border-bottom: .5px solid var(--separator); }
.wb-panel { padding: .75rem 1rem; background: rgba(var(--ios-blue-rgb), .05); border-bottom: .5px solid var(--separator); }
@media (min-width: 768px) {
    /* 轉給同事、結案：浮在標題列下方，不推動訊息串 */
    .wb-panel {
        position: absolute; top: 3.8rem; right: 1rem; z-index: 20; width: min(25rem, calc(100% - 2rem)); padding: .9rem 1rem;
        background: var(--surface); border: .5px solid var(--separator); border-radius: 14px; box-shadow: var(--shadow-float);
    }
}
.wb-thread-wrap { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.wb-thread { position: relative; flex: 1; min-height: 0; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .5rem; }
.wb-new-msg {
    position: absolute; left: 50%; bottom: .75rem; transform: translateX(-50%); z-index: 5; padding: .35rem .95rem;
    border: 0; border-radius: 999px; background: var(--ios-blue); color: #fff; font-size: .82rem; font-weight: 600; box-shadow: var(--shadow-float);
}
.wb-new-msg[hidden] { display: none; }
.wb-day { align-self: stretch; display: flex; align-items: center; gap: .6rem; margin: .35rem 0; color: var(--label-tertiary); font-size: .72rem; font-weight: 600; }
.wb-day::before, .wb-day::after { content: ""; flex: 1; height: .5px; background: var(--separator); }
.wb-msg { display: flex; flex-direction: column; max-width: 78%; }
.wb-msg.visitor { align-self: flex-start; align-items: flex-start; }
.wb-msg.ai, .wb-msg.agent { align-self: flex-end; align-items: flex-end; }
.wb-msg.system { align-self: center; align-items: center; max-width: 90%; }
.wb-who { font-size: .72rem; color: var(--label-secondary); margin: 0 .5rem .15rem; }
.wb-bubble { padding: .5rem .85rem; border-radius: 16px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.wb-bubble.md { white-space: normal; }
.wb-bubble.md > :last-child { margin-bottom: 0; }
.wb-bubble.md p, .wb-bubble.md ul, .wb-bubble.md ol { margin: 0 0 .4em; }
.wb-msg.visitor .wb-bubble { background: #e9e9eb; border-bottom-left-radius: 5px; }
.wb-msg.ai .wb-bubble { background: rgba(var(--ios-blue-rgb), .1); border-bottom-right-radius: 5px; }
.wb-msg.agent .wb-bubble { background: var(--ios-blue); color: #fff; border-bottom-right-radius: 5px; }
.wb-msg.agent .wb-bubble.md a { color: #fff; }
.wb-msg.note .wb-bubble { background: rgba(255, 204, 0, .2); color: var(--label); border: 1px dashed rgba(194, 109, 0, .45); }
.wb-note { font-size: .78rem; color: var(--label-secondary); background: var(--fill); border-radius: 10px; padding: .3rem .7rem; text-align: center; }
.wb-msg.note .wb-note { background: rgba(255, 204, 0, .16); }
.wb-image { margin-bottom: .25rem; max-width: 260px; }
.wb-image img { max-width: 260px; max-height: 200px; border-radius: 12px; border: .5px solid var(--separator); display: block; cursor: zoom-in; }
.wb-image summary { font-size: .75rem; color: var(--ios-blue); cursor: pointer; margin-top: .2rem; }
.wb-typing { padding: 0 1rem .3rem; }
.wb-accept-bar { display: flex; align-items: center; gap: .75rem; padding: .6rem 1rem; border-top: .5px solid var(--separator); background: rgba(var(--ios-blue-rgb), .06); }
.wb-accept-bar[hidden] { display: none; }
.wb-accept-text { flex: 1; min-width: 0; font-size: .88rem; font-weight: 600; color: var(--label); }
.wb-accept-bar .btn { margin-left: auto; padding-left: 1.5rem; padding-right: 1.5rem; font-weight: 600; }
.wb-composer { position: relative; padding: .7rem 1rem; border-top: .5px solid var(--separator); background: rgba(248, 250, 253, .9); }
.wb-composer-bar { display: flex; align-items: center; gap: .75rem; margin-bottom: .5rem; }
.wb-hint-close { border: 0; background: none; padding: 0 .3rem; color: var(--label-tertiary); line-height: 1; }
.wb-hint-close:hover { color: var(--label); }
.wb-counter { margin-left: auto; color: var(--label-secondary); font-variant-numeric: tabular-nums; }
.wb-counter.warn { color: #d70015; font-weight: 600; }
.wb-composer textarea { resize: none; }
.wb-composer.note-mode textarea { background: #fff8db; border-color: rgba(194, 109, 0, .45); }
.wb-composer.note-mode textarea:focus { box-shadow: 0 0 0 .2rem rgba(255, 204, 0, .3); }
.wb-canned {
    position: absolute; left: 1rem; right: 1rem; bottom: 100%; margin-bottom: .3rem; z-index: 5; max-height: 50vh; overflow-y: auto;
    background: #fff; border-radius: 12px; box-shadow: var(--shadow-float);
}
.wb-canned button { display: block; width: 100%; text-align: left; border: none; background: #fff; padding: .45rem .8rem; font-size: .85rem; }
.wb-canned button:first-child { background: rgba(var(--ios-blue-rgb), .07); }
@media (hover: hover) { .wb-canned button:hover { background: rgba(var(--ios-blue-rgb), .07); } }

/* 對話資訊 */
.wb-info { overflow-y: auto; }
.wb-info .section-label { margin-left: 0; }
.wb-info-row { margin-bottom: .55rem; font-size: .88rem; }
.wb-leave { background: var(--fill); border-radius: 10px; padding: .5rem .7rem; font-size: .88rem; margin: .3rem 0; }
.wb-info-close { position: sticky; top: 0; z-index: 1; display: flex; justify-content: space-between; align-items: center; padding: .6rem 1rem; background: var(--surface); border-bottom: .5px solid var(--separator); }
@media (min-width: 1200px) { .wb-info-close { display: none; } }
.wb-sheet-backdrop { display: none; }
@media (min-width: 768px) and (max-width: 1199.98px) {
    .wb-grid { grid-template-columns: 300px minmax(0, 1fr); }
    /* 對話資訊：ⓘ 打開右側抽屜 */
    .wb-sheet-backdrop { position: fixed; inset: 0; z-index: 1040; background: rgba(0, 0, 0, .25); }
    .wb.info-open .wb-sheet-backdrop { display: block; }
    .wb-info { position: fixed; top: 0; right: 0; bottom: 0; z-index: 1045; width: min(22rem, 90vw); border-radius: 16px 0 0 16px; }
    .wb:not(.info-open) .wb-info { display: none; }
}
@media (min-width: 768px) and (max-width: 991.98px) { .wb-grid { grid-template-columns: 260px minmax(0, 1fr); } }

.wb-toast {
    position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 2000; max-width: 22rem;
    background: rgba(28, 28, 30, .92); color: #fff; padding: .65rem 1rem; border-radius: 12px; box-shadow: var(--shadow-float); font-size: .9rem;
}
.wb-toast.error { background: rgba(215, 0, 21, .94); }
.wb-toast.clickable { cursor: pointer; }
.wb-lightbox { position: fixed; inset: 0; z-index: 2050; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem; padding: 1.5rem; background: rgba(0, 0, 0, .85); }
.wb-lightbox[hidden] { display: none; }
.wb-lightbox img { max-width: 100%; max-height: calc(100% - 4rem); object-fit: contain; border-radius: 8px; }
.wb-lightbox-bar { display: flex; gap: .5rem; }
.wb-shortcuts td { border-color: var(--separator); vertical-align: middle; font-size: .88rem; }
.wb-shortcuts td:first-child { width: 1%; padding-right: 1.25rem; white-space: nowrap; }

/* 頁首的上線狀態（所有後台頁面） */
.nav-presence {
    align-items: center; gap: .4rem; padding: .25rem .75rem; border: .5px solid var(--separator); border-radius: 999px;
    background: rgba(255, 255, 255, .7); color: var(--label); font-size: .85rem; font-weight: 600; text-decoration: none; white-space: nowrap;
}
.nav-presence:hover { background: #fff; color: var(--label); }
.nav-presence-dot { width: .55rem; height: .55rem; border-radius: 50%; background: var(--label-tertiary); }
.nav-presence[data-state="on"] .nav-presence-dot { background: var(--ios-green); box-shadow: 0 0 0 3px rgba(52, 199, 89, .2); }
.nav-presence[data-state="away"] .nav-presence-dot { background: var(--ios-orange); }
.nav-presence[data-state="off"] { color: var(--label-secondary); }

.wb-ext { padding: .6rem 1rem; border-bottom: .5px solid var(--separator); display: grid; gap: .5rem; max-height: 38%; overflow-y: auto; }
.wb-ext[hidden] { display: none; }
.wb-ext > a { justify-self: start; }
.wb-ext-card { background: var(--fill); border-radius: 10px; padding: .45rem .7rem; font-size: .86rem; }
.wb-ext-card .wb-ext-title { font-size: .72rem; font-weight: 600; color: var(--label-secondary); margin-bottom: .15rem; }
.wb-ext-card.diagnosis { background: rgba(255, 149, 0, .1); }
.wb-ext-banner { background: rgba(215, 0, 21, .08); color: #d70015; border-radius: 10px; padding: .45rem .7rem; font-size: .86rem; font-weight: 600; }
.wb-ext-toggle { display: none; }
.wb-icon-btn { min-width: 2.25rem; }

/* ---------- 工作台（手機）：整頁固定高度、清單與對話一次只顯示一層、只有清單與訊息串會捲動 ---------- */
@media (max-width: 767.98px) {
    body.wb-page { height: var(--wb-app-h, 100dvh); display: flex; flex-direction: column; overflow: hidden; }
    body.wb-page > header { flex-shrink: 0; }
    body.wb-page > main { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: .6rem 12px 0 !important; }
    body.wb-page.wb-in-chat > header { display: none; }
    body.wb-page.wb-in-chat > main { padding: 0 !important; }

    .wb { flex: 1; min-height: 0; display: flex; flex-direction: column; }
    .wb-top { margin-bottom: .6rem !important; }
    .wb-top-title { display: block; }
    .wb-top .large-title { font-size: 1.35rem; }
    .wb[data-view="chat"] .wb-top { display: none !important; }
    .wb-banner { margin-bottom: .5rem; }
    .wb[data-view="chat"] .wb-banner { margin-bottom: 0; border-radius: 0; }

    .wb-grid { display: flex; flex-direction: column; flex: 1; min-height: 0; height: auto; gap: 0; }
    .wb-list, .wb-chat { flex: 1; min-height: 0; }
    .wb-list { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
    .wb[data-view="list"] .wb-chat, .wb[data-view="chat"] .wb-list { display: none; }
    .wb[data-view="chat"] .wb-chat { border-radius: 0; border: 0; }

    /* 分頁：單行左右滑動，點擊範圍 40px 以上 */
    .wb-tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
    .wb-tabs::-webkit-scrollbar { display: none; }
    .wb-tabs button { flex-shrink: 0; min-height: 40px; padding: .4rem .8rem; font-size: .9rem; }
    .wb-more { display: none; }
    .wb-item { padding: .75rem 1rem; }
    .wb-item:active { background: var(--fill); }
    .wb-badge-wide { display: none !important; }

    /* iOS：欄位字級小於 16px 時聚焦會自動放大畫面 */
    .wb textarea, .wb input:not([type=checkbox]):not([type=radio]), .wb select, body.wb-page .select2-search__field { font-size: 16px !important; }
    .wb .select2-container.select2-sm .select2-selection--single { font-size: 16px; }
    .wb-search input { padding-right: .75rem; }

    .wb-chat-header { padding: .5rem .6rem; gap: .4rem; position: relative; }
    .wb-back { font-size: 2rem; line-height: 1; padding: 0 .5rem .2rem; text-decoration: none; }
    .wb-icon-btn { min-height: 2.25rem; }
    .wb-thread { padding: .75rem; }
    .wb-msg { max-width: 86%; }
    .wb-image, .wb-image img { max-width: 100%; }

    /* 外部轉接卡片：預設收合成一行 */
    .wb-ext { padding: .5rem .75rem; max-height: 45%; }
    .wb-ext-toggle {
        display: flex; align-items: center; gap: .4rem; width: 100%; border: 0; background: var(--fill); border-radius: 10px;
        padding: .45rem .7rem; font-size: .86rem; text-align: left; color: var(--label);
    }
    .wb-ext-toggle .wb-ext-chev {
        flex-shrink: 0; margin: 0 .2rem -.1rem auto; width: .5rem; height: .5rem; position: relative; top: -.15rem;
        border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); transition: transform .15s ease;
    }
    .wb-ext:not(.collapsed) .wb-ext-toggle .wb-ext-chev { transform: rotate(-135deg); top: .1rem; }
    .wb-ext.collapsed > :not(.wb-ext-toggle):not(.wb-ext-banner) { display: none; }

    .wb-accept-bar { padding: .6rem .75rem; background: rgba(248, 250, 253, .95); }
    .wb-accept-bar .btn { width: 100%; min-height: 44px; margin-left: 0; }
    .wb-composer { padding: .55rem .75rem calc(.55rem + env(safe-area-inset-bottom)); }
    .wb-composer .btn { min-height: 44px; }
    .wb-canned { left: .75rem; right: .75rem; }
    .wb-canned button { padding: .65rem .8rem; }

    /* 對話資訊：從底部滑出 */
    .wb-sheet-backdrop { position: fixed; inset: 0; z-index: 1040; background: rgba(0, 0, 0, .3); }
    .wb.info-open .wb-sheet-backdrop { display: block; }
    .wb-info {
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 1045; max-height: 85dvh;
        border-radius: 16px 16px 0 0; padding-bottom: env(safe-area-inset-bottom);
    }
    .wb:not(.info-open) .wb-info { display: none; }

    /* 在對話標題列下方出現、不擋點擊（返回鍵、⋯ 仍可按） */
    .wb-toast { top: calc(4rem + env(safe-area-inset-top)); bottom: auto; left: 12px; right: 12px; max-width: none; text-align: center; pointer-events: none; }
    .wb-toast.clickable { pointer-events: auto; }
    .wb-panel .btn { min-height: 40px; padding-left: 1rem; padding-right: 1rem; }
}

/* ---------- 登入頁 ---------- */
.auth-body {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    padding: 1rem;
    background:
        radial-gradient(600px 400px at 15% 20%, rgba(90, 200, 250, .45), transparent 70%),
        radial-gradient(700px 500px at 90% 85%, rgba(0, 122, 255, .35), transparent 70%),
        linear-gradient(160deg, #dcebfb 0%, #eef5fd 50%, #d6e6fa 100%);
}
.auth-body::before { height: 100vh; mask-image: none; opacity: .7; }
.auth-card {
    width: 100%; max-width: 25rem;
    background: rgba(255, 255, 255, .78);
    backdrop-filter: saturate(180%) blur(24px);
    -webkit-backdrop-filter: saturate(180%) blur(24px);
    box-shadow: var(--shadow-float);
    border-radius: 22px;
}
.auth-logo {
    width: 56px; height: 56px; border-radius: 15px; margin: 0 auto .8rem;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--ios-blue), var(--ios-cyan));
    color: #fff; font-weight: 800; font-size: 1.05rem;
    box-shadow: 0 10px 24px rgba(var(--ios-blue-rgb), .35);
}
.auth-brand { font-size: 1.45rem; font-weight: 700; letter-spacing: -.01em; }
.auth-card .validation-summary-errors ul { list-style: none; padding: 0; margin: 0; }
.auth-card .form-switch { gap: .6em; }

/* ---------- 公開端：服務暫停頁（對話頁樣式在 chat.css） ---------- */
.public-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.public-placeholder { max-width: 28rem; }
.public-avatar {
    width: 4rem; height: 4rem; margin: 0 auto; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 1.5rem; font-weight: 700;
}

@media (max-width: 767.98px) {
    .large-title { font-size: 1.6rem; }
    .card-body { padding: 1.05rem 1.1rem; }
    .chat-row { max-width: 92%; }
}

/* ---------- 報表（M6） ---------- */
:root {
    /* 三分類：固定順序，已用 dataviz 驗證器檢查色覺辨識（淺色底） */
    --series-answerable: #007aff;
    --series-related: #e07800;
    --series-unrelated: #8e5bd8;
}
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .75rem; }
.kpi-grid .stat-sub { font-size: .76rem; color: var(--label-tertiary); margin-top: .1rem; }
.bar-chart { display: flex; align-items: flex-end; gap: 2px; height: 180px; padding-top: 1.2rem; border-bottom: 1px solid var(--separator); }
.bar-chart .bar-col { flex: 1 1 0; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; position: relative; cursor: default; }
.bar-chart .bar-col:hover { background: rgba(var(--ios-blue-rgb), .06); border-radius: 4px 4px 0 0; }
.bar-chart .bar { background: var(--ios-blue); border-radius: 4px 4px 0 0; min-height: 0; }
.bar-chart .bar-col:hover .bar { background: var(--ios-blue-dark); }
.bar-chart .bar-tip {
    display: none; position: absolute; bottom: calc(100% - 1rem); left: 50%; transform: translateX(-50%);
    background: var(--label); color: #fff; font-size: .75rem; padding: .25rem .5rem; border-radius: 6px; white-space: nowrap; z-index: 2; pointer-events: none;
}
.bar-chart .bar-col:hover .bar-tip, .bar-chart .bar-col:focus .bar-tip { display: block; }
.bar-axis { display: flex; gap: 2px; font-size: .72rem; color: var(--label-secondary); margin-top: .3rem; }
.bar-axis span { flex: 1 1 0; min-width: 0; text-align: center; overflow: visible; white-space: nowrap; display: flex; justify-content: center; }
.share-bar { display: flex; gap: 2px; height: 14px; border-radius: 4px; overflow: hidden; background: var(--fill); }
.share-bar > div { height: 100%; }
.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: .35rem; vertical-align: -1px; }
.topic-card .topic-count { font-size: 1.4rem; font-weight: 700; line-height: 1; }
.topic-card .topic-samples li { margin-bottom: .2rem; }
.transcript .bubble-row { display: flex; margin-bottom: .6rem; }
.transcript .bubble-row.visitor { justify-content: flex-end; }
.transcript .t-bubble { max-width: 78%; padding: .55rem .85rem; border-radius: 18px; background: #fff; box-shadow: 0 1px 2px rgba(16, 42, 84, .06); }
.transcript .visitor .t-bubble { background: var(--ios-blue); color: #fff; }
.transcript .agent .t-bubble { background: #e8f8ee; }
.transcript .system .t-bubble, .transcript .note .t-bubble { background: var(--fill); font-size: .86rem; color: var(--label-secondary); }
.transcript .note .t-bubble { background: #fff6e0; }
.transcript .t-meta { font-size: .72rem; color: var(--label-secondary); margin-top: .2rem; }
.transcript .visitor .t-meta { color: rgba(255, 255, 255, .85); }
.transcript .t-bubble img { max-width: 220px; border-radius: 10px; margin-top: .35rem; display: block; }

/* ---------- Select2（對齊 .form-select 的 iOS 外觀） ---------- */
.select2-container--default .select2-selection--single {
    height: auto;
    background-color: var(--fill);
    border: 1px solid transparent;
    border-radius: var(--radius-control);
    padding: .55rem 2.2rem .55rem .8rem;
    transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.select2-container--default .select2-selection--single .select2-selection__rendered { color: var(--label); line-height: 1.5; padding: 0; }
.select2-container--default .select2-selection--single .select2-selection__arrow { height: 100%; top: 0; right: .55rem; }
.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container--default.select2-container--open .select2-selection--single {
    background-color: #fff;
    border-color: var(--ios-blue);
    box-shadow: 0 0 0 4px rgba(var(--ios-blue-rgb), .15);
}
.select2-container--default.select2-container--disabled .select2-selection--single { background-color: rgba(118, 118, 128, .07); }
.select2-container.select2-sm .select2-selection--single { font-size: .875rem; }
.select2-dropdown {
    border: 0;
    border-radius: 14px;
    padding: .35rem;
    box-shadow: var(--shadow-float);
    background: rgba(255, 255, 255, .96);
    z-index: 1060;
}
.select2-container--open .select2-dropdown--below,
.select2-container--open .select2-dropdown--above { border-radius: 14px; margin-top: 4px; }
.select2-container--open .select2-dropdown--above { margin-top: -4px; }
.select2-results__option { border-radius: 9px; padding: .45rem .8rem; font-size: .92rem; }
.select2-container--default .select2-results__option--highlighted.select2-results__option--selectable { background-color: var(--ios-blue); color: #fff; }
.select2-container--default .select2-results__option--selected { background-color: var(--fill-strong); }
.select2-container--default .select2-search--dropdown { padding: .15rem .15rem .4rem; }
.select2-container--default .select2-search--dropdown .select2-search__field {
    border: 1px solid transparent;
    border-radius: 8px;
    background: var(--fill);
    padding: .4rem .65rem;
    outline: none;
}
.select2-container--default .select2-search--dropdown .select2-search__field:focus { background: #fff; border-color: var(--ios-blue); }

/* ---------- daterangepicker ---------- */
.form-control.picker-input[readonly] { background-color: var(--fill); cursor: pointer; }
.form-control.picker-input[readonly]:focus { background-color: #fff; }
.daterangepicker {
    border: 0;
    border-radius: 14px;
    box-shadow: var(--shadow-float);
    font-family: inherit;
    z-index: 1060;
}
.daterangepicker::before, .daterangepicker::after { display: none; }
.daterangepicker .calendar-table th, .daterangepicker .calendar-table td { border-radius: 8px; }
.daterangepicker td.active, .daterangepicker td.active:hover { background-color: var(--ios-blue); }
.daterangepicker td.in-range { background-color: rgba(var(--ios-blue-rgb), .1); }
.daterangepicker td.start-date { border-radius: 8px 0 0 8px; }
.daterangepicker td.end-date { border-radius: 0 8px 8px 0; }
.daterangepicker td.start-date.end-date { border-radius: 8px; }
.daterangepicker .ranges li { border-radius: 8px; margin: 2px 6px; }
.daterangepicker .ranges li.active { background-color: var(--ios-blue); }
.daterangepicker select.hourselect, .daterangepicker select.minuteselect,
.daterangepicker select.monthselect, .daterangepicker select.yearselect {
    background: var(--fill); border: 0; border-radius: 6px; padding: 2px 4px;
}
.daterangepicker .drp-buttons .btn { border-radius: 8px; }
.daterangepicker .drp-buttons .btn-primary { background-color: var(--ios-blue); border-color: var(--ios-blue); }
/* 只選時間：隱藏月曆與選取日期文字 */
.daterangepicker.time-only .calendar-table,
.daterangepicker.time-only .drp-selected { display: none !important; }
.daterangepicker.time-only .calendar-time { margin: 10px 8px 4px; }
