/* ==========================================================================
   CS Support Desk — Design System
   中性底 / 细描边 / 大留白 / 单一强调色
   ========================================================================== */

:root {
    --bg: #f7f8fa;
    --surface: #ffffff;
    --surface-2: #fbfcfd;
    --ink: #0b0f17;
    --ink-2: #344054;
    --muted: #667085;
    --muted-2: #98a2b3;
    --line: #e7e9ee;
    --line-2: #d5d9e0;

    --accent: #2563eb;
    --accent-ink: #1d4ed8;
    --accent-soft: #eef4ff;

    --ok: #067647;
    --ok-soft: #ecfdf3;
    --warn: #b54708;
    --warn-soft: #fffaeb;
    --danger: #b42318;
    --danger-soft: #fef3f2;

    --r-xs: 6px;
    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 16px;

    --shadow-xs: 0 1px 2px rgba(16, 24, 40, .04);
    --shadow-sm: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
    --shadow-lg: 0 12px 32px rgba(16, 24, 40, .10);

    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Noto Sans JP", "Yu Gothic", Meiryo, sans-serif;
    --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

    --ease: cubic-bezier(.2, .8, .2, 1);
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.6;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    letter-spacing: -0.005em;
}

button, input, textarea, select { font: inherit; color: inherit; letter-spacing: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, kbd { font-family: var(--mono); font-size: .92em; }

::selection { background: #dbe7ff; }

/* ---------- 基础组件 ---------- */

.btn {
    --btn-bg: var(--accent);
    --btn-ink: #fff;
    --btn-border: transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 38px;
    padding: 0 16px;
    border: 1px solid var(--btn-border);
    border-radius: var(--r-sm);
    background: var(--btn-bg);
    color: var(--btn-ink);
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background .16s var(--ease), border-color .16s, box-shadow .16s, transform .06s;
}
.btn:hover { background: var(--accent-ink); }
.btn:active { transform: translateY(.5px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(37, 99, 235, .18); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.ghost { --btn-bg: #fff; --btn-ink: var(--ink-2); --btn-border: var(--line-2); }
.btn.ghost:hover { --btn-bg: var(--surface-2); }
.btn.soft { --btn-bg: #f2f4f7; --btn-ink: var(--ink-2); --btn-border: transparent; }
.btn.soft:hover { --btn-bg: #eaecf0; }
.btn.danger { --btn-bg: #fff; --btn-ink: var(--danger); --btn-border: #fda29b; }
.btn.danger:hover { --btn-bg: var(--danger-soft); }
.btn.sm { height: 32px; padding: 0 12px; font-size: 12.5px; border-radius: var(--r-xs); }

.field {
    width: 100%;
    min-height: 38px;
    padding: 9px 12px;
    background: #fff;
    border: 1px solid var(--line-2);
    border-radius: var(--r-sm);
    color: var(--ink);
    font-size: 13.5px;
    outline: none;
    transition: border-color .16s, box-shadow .16s;
}
.field::placeholder { color: var(--muted-2); }
.field:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
textarea.field { line-height: 1.7; resize: vertical; }
select.field { appearance: none; background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23667085' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }

.label { display: block; margin: 14px 0 6px; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.hint { font-size: 12px; line-height: 1.7; color: var(--muted); }
.muted { color: var(--muted); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.card-head h2 { margin: 0; font-size: 14px; font-weight: 650; letter-spacing: -.01em; }
.card-body { padding: 20px; }

.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 11px; font-weight: 600; background: #f2f4f7; color: var(--ink-2); border: 1px solid transparent; }
.badge.ai { background: var(--accent-soft); color: var(--accent-ink); }
.badge.human { background: var(--warn-soft); color: var(--warn); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.off { background: #f2f4f7; color: var(--muted); }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

hr.sep { border: none; border-top: 1px solid var(--line); margin: 20px 0; }

/* ==========================================================================
   客户端
   ========================================================================== */

.client-shell { min-height: 100%; display: flex; justify-content: center; background: var(--bg); }
.client-frame {
    width: 100%;
    max-width: 480px;
    min-height: 100vh;
    height: var(--app-h, 100dvh);
    background: var(--surface);
    display: flex;
    flex-direction: column;
    position: relative;
}
@media (min-width: 640px) {
    .client-shell { padding: 32px 0; }
    .client-frame { min-height: calc(100vh - 64px); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); overflow: hidden; }
}

.client-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
    position: sticky;
    top: 0;
    z-index: 20;
}
.brand-box { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.brand-name { font-size: 14.5px; font-weight: 650; letter-spacing: -.01em; }
.brand-sub { font-size: 10px; letter-spacing: .16em; color: var(--muted-2); text-transform: uppercase; }
.secure-tag { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; white-space: nowrap; }
.secure-tag::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }

.client-main { flex: 1; padding: 28px 20px 104px; }

.notice { margin-bottom: 26px; }
.notice h2 { margin: 0 0 10px; font-size: 18px; font-weight: 650; letter-spacing: -.02em; }
.notice .body { font-size: 13.5px; line-height: 1.85; color: var(--ink-2); }
.notice .body p { margin: 0 0 10px; }
.notice .body p:last-child { margin: 0; }

.auth-block { display: flex; flex-direction: column; gap: 2px; }
.auth-title { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 650; color: var(--ink); margin-bottom: 4px; }
.auth-title .req { font-size: 10px; font-weight: 700; color: var(--danger); background: var(--danger-soft); border-radius: 4px; padding: 1px 5px; }

.promo-card {
    position: relative;
    display: block;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: 16px;
    background: var(--surface);
    cursor: pointer;
    transition: border-color .16s, box-shadow .16s, transform .12s var(--ease);
}
.promo-card:hover { border-color: var(--line-2); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.promo-icon { float: right; width: 40px; height: 40px; border-radius: 10px; object-fit: cover; margin-left: 12px; border: 1px solid var(--line); }
.promo-badge { display: inline-block; font-size: 10.5px; font-weight: 650; letter-spacing: .06em; color: var(--accent-ink); background: var(--accent-soft); border-radius: 5px; padding: 2px 7px; }
.promo-title { margin: 10px 0 6px; font-size: 15px; font-weight: 650; letter-spacing: -.01em; }
.promo-desc { font-size: 12.5px; line-height: 1.75; color: var(--muted); }
.promo-cta { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 12.5px; font-weight: 600; color: var(--accent-ink); }

.welcome-line { margin: 0 0 20px; font-size: 13.5px; line-height: 1.85; color: var(--ink-2); }
.trust-line { margin-top: 26px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 11.5px; line-height: 1.75; color: var(--muted-2); }

.launcher {
    position: fixed;
    z-index: 30;
    right: max(20px, calc(50vw - 220px));
    bottom: 22px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    height: 46px;
    padding: 0 18px;
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 999px;
    background: var(--ink);
    color: #fff;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(11, 15, 23, .18);
    transition: transform .12s var(--ease), box-shadow .16s;
}
.launcher:hover { transform: translateY(-1px); box-shadow: 0 12px 28px rgba(11, 15, 23, .22); }
.launcher .dot { width: 7px; height: 7px; border-radius: 50%; background: #32d583; box-shadow: 0 0 0 3px rgba(50, 213, 131, .18); }
.launcher .count { display: none; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); font-size: 10.5px; font-weight: 700; }

/* 排队 */
.queue-card { border: 1px solid var(--line); border-radius: var(--r-md); padding: 22px; background: var(--surface); }
.queue-kicker { display: inline-block; font-size: 11px; font-weight: 600; letter-spacing: .08em; color: var(--warn); background: var(--warn-soft); border-radius: 5px; padding: 3px 8px; }
.queue-card h2 { margin: 14px 0 8px; font-size: 18px; font-weight: 650; letter-spacing: -.02em; }
.queue-stats { display: flex; gap: 28px; margin: 20px 0 16px; }
.queue-stats div { display: flex; flex-direction: column; }
.queue-stats b { font-size: 28px; font-weight: 650; letter-spacing: -.02em; }
.queue-stats span { font-size: 11.5px; color: var(--muted); }
.queue-bar { height: 4px; border-radius: 2px; background: #f2f4f7; overflow: hidden; }
.queue-bar i { display: block; height: 100%; width: 20%; background: var(--accent); border-radius: 2px; transition: width .6s var(--ease); }

/* 入站加载态 */
.loading-box { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 80px 0; color: var(--muted); font-size: 13px; }
.spinner { width: 26px; height: 26px; border: 2px solid var(--line); border-top-color: var(--ink-2); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 聊天面板 */
.chat-panel {
    position: fixed;
    inset: auto 0 0 0;
    margin: 0 auto;
    max-width: 480px;
    height: 100vh;
    background: var(--surface);
    z-index: 40;
    display: flex;
    flex-direction: column;
    transform: translateY(102%);
    transition: transform .28s var(--ease);
    box-shadow: var(--shadow-lg);
}
.chat-panel.open { transform: translateY(0); }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); background: var(--surface); }
.chat-head .back { width: 32px; height: 32px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: var(--r-xs); background: #fff; color: var(--ink-2); font-size: 16px; line-height: 1; cursor: pointer; }
.chat-head .back:hover { background: var(--surface-2); }
.chat-head .title { flex: 1; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.chat-head .title b { font-size: 14px; font-weight: 650; }
.chat-head .pill { align-self: flex-start; font-size: 10.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-ink); }
.chat-head .pill.human { background: var(--warn-soft); color: var(--warn); }

.chat-body { flex: 1; overflow-y: auto; padding: 20px 16px 8px; background: var(--bg); display: flex; flex-direction: column; gap: 16px; }
.msg { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; max-width: 100%; }
.msg .who { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted-2); padding-left: 2px; }
.msg .bubble { max-width: 82%; padding: 11px 14px; border-radius: 14px; font-size: 13.5px; line-height: 1.75; white-space: pre-wrap; word-break: break-word; }
.msg.them .bubble { background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 4px; color: var(--ink); }
.msg.me { align-items: flex-end; }
.msg.me .bubble { background: var(--ink); color: #fff; border-bottom-right-radius: 4px; }
.msg .time { font-size: 10.5px; color: var(--muted-2); }

.typing { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); padding: 2px 2px 10px; }
.typing .dots span { display: inline-block; width: 5px; height: 5px; margin-right: 3px; border-radius: 50%; background: var(--muted-2); animation: bounce 1.2s infinite; }
.typing .dots span:nth-child(2) { animation-delay: .15s; }
.typing .dots span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .35; } 30% { transform: translateY(-3px); opacity: 1; } }

.chat-foot { display: flex; gap: 8px; padding: 12px 14px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--surface); }
.chat-foot input { flex: 1; height: 42px; padding: 0 14px; border: 1px solid var(--line-2); border-radius: 999px; outline: none; font-size: 13.5px; background: var(--surface-2); }
.chat-foot input:focus { border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px rgba(37, 99, 235, .1); }
.chat-foot .btn { height: 42px; border-radius: 999px; padding: 0 18px; }

/* 弹层 */
.sheet { position: fixed; inset: 0; z-index: 60; display: none; align-items: flex-end; justify-content: center; background: rgba(11, 15, 23, .4); backdrop-filter: blur(2px); }
.sheet.open { display: flex; }
.sheet-box { width: 100%; max-width: 480px; max-height: 92vh; overflow-y: auto; background: var(--surface); border-radius: var(--r-lg) var(--r-lg) 0 0; padding: 20px 20px calc(24px + env(safe-area-inset-bottom)); animation: sheetUp .24s var(--ease); }
@keyframes sheetUp { from { transform: translateY(24px); opacity: .7; } to { transform: none; opacity: 1; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.sheet-head h3 { margin: 0; font-size: 15px; font-weight: 650; }
.sheet-close { width: 30px; height: 30px; border: 1px solid var(--line); border-radius: var(--r-xs); background: #fff; color: var(--muted); font-size: 13px; cursor: pointer; }
.sheet-close:hover { background: var(--surface-2); }

.device-tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-xs); padding: 6px 10px; margin-bottom: 14px; }
.step-row { display: flex; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; line-height: 1.75; color: var(--ink-2); }
.step-row:last-child { border-bottom: none; }
.step-no { flex: 0 0 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; background: var(--accent-soft); color: var(--accent-ink); font-size: 11.5px; font-weight: 700; }
.store { display: flex; align-items: center; justify-content: center; gap: 8px; height: 44px; margin-top: 10px; border-radius: var(--r-sm); border: 1px solid transparent; font-size: 13.5px; font-weight: 600; }
.store:hover { text-decoration: none; opacity: .92; }
.store.ios { background: var(--ink); color: #fff; }
.store.android { background: #067647; color: #fff; }
.store.apk { background: #fff; color: var(--ink); border-color: var(--line-2); }
.note-box { margin-top: 14px; padding: 11px 13px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); font-size: 11.5px; line-height: 1.8; color: var(--muted); }

.zh-ref { margin-top: 8px; padding-top: 7px; border-top: 1px dashed rgba(14, 159, 110, .28); font-size: 11.5px; line-height: 1.7; color: #0e9f6e; white-space: pre-wrap; }
.zh-ref.pending { opacity: .6; font-style: italic; cursor: pointer; color: var(--muted); }
.zh-ref.failed { color: var(--warn); cursor: pointer; }
.msg.me .zh-ref { color: #86efac; border-top-color: rgba(134, 239, 172, .28); }

/* ==========================================================================
   后台
   ========================================================================== */

.admin-body { display: flex; height: 100vh; overflow: hidden; background: var(--bg); }

.rail { width: 212px; flex: 0 0 212px; display: flex; flex-direction: column; gap: 2px; padding: 16px 12px; background: var(--surface); border-right: 1px solid var(--line); }
.rail .logo { display: flex; align-items: center; gap: 10px; padding: 6px 8px 18px; font-size: 13.5px; font-weight: 650; letter-spacing: -.01em; }
.rail .logo .mark { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 7px; background: var(--ink); color: #fff; font-size: 12px; font-weight: 700; }
.rail button { display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 10px; border: 1px solid transparent; border-radius: var(--r-sm); background: transparent; color: var(--ink-2); font-size: 13px; font-weight: 500; cursor: pointer; text-align: left; }
.rail button i { display: grid; place-items: center; width: 18px; height: 18px; font-style: normal; color: var(--muted); }
.rail button i svg { width: 17px; height: 17px; }
.rail button:hover { background: #f4f5f7; color: var(--ink); }
.rail button.active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.rail button.active i { color: var(--accent); }
.rail .spacer { flex: 1; }
.rail button.signout { color: var(--muted); }

.admin-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.admin-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 56px; padding: 0 24px; background: var(--surface); border-bottom: 1px solid var(--line); }
.admin-top h1 { margin: 0; font-size: 14.5px; font-weight: 650; letter-spacing: -.01em; }
.admin-top .who { display: flex; align-items: center; gap: 14px; font-size: 12px; color: var(--muted); }
.admin-top .who .avatar { width: 24px; height: 24px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-ink); display: grid; place-items: center; font-size: 11px; font-weight: 700; }

.view { flex: 1; overflow: hidden; display: none; }
.view.active { display: flex; }

/* 会话 */
.conv-list { width: 320px; flex: 0 0 320px; display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--line); overflow: hidden; }
.conv-search { padding: 12px; border-bottom: 1px solid var(--line); }
.conv-search .field { height: 34px; background: var(--surface-2); }
.conv-items { flex: 1; overflow-y: auto; }
.conv-item { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.conv-item:hover { background: #fafbfc; }
.conv-item.active { background: var(--accent-soft); }
.conv-item .row1 { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.conv-item .nm { font-size: 13px; font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-item .code { font-family: var(--mono); font-size: 10.5px; color: var(--muted-2); }
.conv-item .prev { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-item .meta { display: flex; align-items: center; gap: 6px; }
.conv-item .meta .muted { margin-left: auto; font-size: 10.5px; }
.unread { display: inline-flex; align-items: center; justify-content: center; min-width: 17px; height: 17px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; }

.thread { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg); }
.thread-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 20px; background: var(--surface); border-bottom: 1px solid var(--line); }
.thread-head .who { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.thread-head .who b { font-size: 13.5px; font-weight: 650; }
.thread-head .who span { font-size: 11.5px; color: var(--muted); }
.thread-head .actions { display: flex; align-items: center; gap: 8px; }
.thread-body { flex: 1; overflow-y: auto; padding: 24px 22px; display: flex; flex-direction: column; gap: 18px; }
.thread-empty { flex: 1; display: grid; place-items: center; color: var(--muted-2); font-size: 13px; }

.thread-foot { display: flex; flex-direction: column; gap: 10px; padding: 12px 16px 14px; background: var(--surface); border-top: 1px solid var(--line); }
.thread-foot .toolbar { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--muted-2); }
.thread-foot .send-row { display: flex; align-items: flex-end; gap: 10px; }
.thread-foot textarea { flex: 1; min-height: 44px; max-height: 140px; padding: 11px 13px; border: 1px solid var(--line-2); border-radius: var(--r-sm); outline: none; resize: none; font-size: 13.5px; line-height: 1.6; }
.thread-foot textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37, 99, 235, .1); }
.trans-row { display: flex; align-items: center; gap: 8px; }
.trans-row .field { height: 34px; font-size: 12.5px; background: var(--surface-2); }
.trans-row #transStatus { font-size: 11px; color: var(--muted-2); min-width: 60px; }

/* 面板 / 表格 */
.pane { flex: 1; overflow-y: auto; padding: 24px; }
.pane-inner { width: 100%; max-width: 1120px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.pane-inner > .card { overflow: hidden; }
.pane h2 { margin: 0 0 4px; font-size: 14px; font-weight: 650; letter-spacing: -.01em; }
.pane .hint { margin-top: 4px; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.stat-row { display: flex; gap: 10px; flex-wrap: wrap; }
.stat { min-width: 120px; padding: 12px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); }
.stat b { display: block; font-size: 18px; font-weight: 650; letter-spacing: -.02em; }
.stat span { font-size: 11.5px; color: var(--muted); }

table.grid { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.grid th { padding: 10px 14px; text-align: left; font-size: 11.5px; font-weight: 600; color: var(--muted); background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
table.grid td { padding: 11px 14px; border-bottom: 1px solid var(--line); color: var(--ink-2); vertical-align: middle; }
table.grid tr:last-child td { border-bottom: none; }
table.grid tbody tr:hover td { background: #fafbfc; }
table.grid code { font-size: 11.5px; color: var(--ink); background: #f2f4f7; border-radius: 4px; padding: 1px 5px; }

/* Agent 卡片 */
.agent-card { border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); margin-bottom: 10px; overflow: hidden; }
.agent-card summary { display: flex; align-items: center; gap: 10px; padding: 13px 16px; cursor: pointer; list-style: none; font-size: 12.5px; }
.agent-card summary::-webkit-details-marker { display: none; }
.agent-card summary b { font-size: 13px; font-weight: 650; }
.agent-card summary code { font-family: var(--mono); font-size: 11px; color: var(--muted); background: #f2f4f7; border-radius: 4px; padding: 1px 5px; }
.agent-card summary .muted { font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-card summary::after { content: '›'; margin-left: auto; color: var(--muted-2); font-size: 15px; transition: transform .16s; }
.agent-card[open] summary::after { transform: rotate(90deg); }
.agent-card[open] summary { border-bottom: 1px solid var(--line); background: var(--surface-2); }
.agent-body { padding: 16px; }
.tool-row { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 12.5px; color: var(--ink-2); }
.tool-row label { display: inline-flex; align-items: center; gap: 6px; }
.tool-row input[type="checkbox"] { accent-color: var(--accent); }

/* 登录 */
.login-wrap { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--bg); }
.login-box { width: 100%; max-width: 360px; padding: 28px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }
.login-box h1 { margin: 0 0 4px; font-size: 18px; font-weight: 650; letter-spacing: -.02em; }
.login-box p { margin: 0 0 20px; font-size: 12.5px; color: var(--muted); }

.toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 10px); padding: 10px 16px; border-radius: var(--r-sm); background: var(--ink); color: #fff; font-size: 12.5px; opacity: 0; pointer-events: none; transition: .2s var(--ease); z-index: 200; box-shadow: var(--shadow-lg); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 900px) {
    .rail { width: 64px; flex-basis: 64px; padding: 12px 8px; align-items: center; }
    .rail .logo { padding: 4px 0 14px; }
    .rail .logo span { display: none; }
    .rail button { justify-content: center; width: 44px; padding: 0; }
    .rail button span { display: none; }
    .two-col { grid-template-columns: 1fr; }
    .conv-list { width: 264px; flex-basis: 264px; }
    .pane { padding: 16px; }
}

.chat-head .conn { font-size: 10.5px; color: var(--muted-2); white-space: nowrap; }
.chat-head .conn.ok { color: #067647; }
.chat-head .conn.bad { color: #b54708; }

/* 正式版聊天窗口（参考简洁客服窗口） */
.client-head { background: var(--brand, var(--accent)); border-bottom: 0; color: #fff; }
.client-head .brand-name, .client-head .brand-sub, .client-head .secure-tag { color: #fff; }
.client-head .secure-tag { opacity: .78; }

.chat-panel { background: #f6f7f8; }
.chat-head {
    background: var(--brand, var(--accent));
    color: #fff;
    border-bottom: 0;
    padding: 14px 16px;
    gap: 10px;
}
.chat-head .back {
    border: 0;
    background: rgba(255, 255, 255, .14);
    color: #fff;
    width: 30px;
    height: 30px;
    font-size: 20px;
}
.chat-head .back:hover { background: rgba(255, 255, 255, .22); }
.chat-head .title b { color: #fff; font-size: 15px; font-weight: 650; letter-spacing: .01em; }
.chat-head .pill { background: rgba(255, 255, 255, .18); color: #fff; font-weight: 500; }
.chat-head .pill.human { background: rgba(255, 255, 255, .24); color: #fff; }
.chat-head .conn, .chat-head .hint { color: rgba(255, 255, 255, .82); }

.chat-body {
    background: #f6f7f8;
    padding: 14px 18px 10px;
    gap: 12px;
}
.chat-date {
    align-self: center;
    background: #e8ebee;
    color: #6b7280;
    font-size: 11px;
    line-height: 1.4;
    padding: 4px 12px;
    border-radius: 999px;
    margin: 2px 0 4px;
    font-variant-numeric: tabular-nums;
}
.agent-intro { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.agent-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    display: grid; place-items: center;
    background: color-mix(in srgb, var(--brand, var(--accent)) 12%, #fff);
    color: var(--brand, var(--accent));
    border: 1px solid color-mix(in srgb, var(--brand, var(--accent)) 16%, #fff);
}
.agent-avatar svg { width: 19px; height: 19px; }
.agent-name { font-size: 12px; color: #4b5563; font-weight: 550; }

.msg.them .bubble {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px 12px 12px 4px;
    padding: 12px 14px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .03);
    color: #1f2937;
}
.msg.me .bubble {
    background: var(--brand, var(--accent));
    border-color: transparent;
    color: #fff;
    border-radius: 12px 12px 4px 12px;
}
.msg.welcome { margin-left: 42px; }
.msg.welcome .bubble {
    background: color-mix(in srgb, var(--brand, var(--accent)) 5%, #fff);
    border-color: color-mix(in srgb, var(--brand, var(--accent)) 12%, #e5e7eb);
}
.welcome-hours { margin-top: 8px; font-size: 11.5px; color: #6b7280; }

.chat-foot {
    background: #fff;
    border-top: 1px solid #e5e7eb;
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
}
.chat-foot input {
    height: 42px;
    border-radius: 999px;
    background: #f3f4f6;
    border: 1px solid transparent;
    padding: 0 16px;
    font-size: 13.5px;
}
.chat-foot input:focus { background: #fff; border-color: color-mix(in srgb, var(--brand, var(--accent)) 45%, #e5e7eb); outline: none; }
.chat-foot .btn {
    height: 42px;
    border-radius: 999px;
    padding: 0 18px;
    background: var(--brand, var(--accent));
    border-color: transparent;
    color: #fff;
    font-weight: 600;
}
.chat-foot .btn:active { transform: translateY(1px); }

/* 头部极简化：只保留品牌与受付时间 */
.chat-head .pill, .chat-head .conn { display: none; }
.chat-head .title b { font-size: 15px; }
.msg.welcome .bubble { max-width: 76%; }

/* 活动入口 */
.intake-card { border: 1px solid #e5e7eb; border-radius: 14px; padding: 22px; background: #fff; margin: 8px 0; }
.intake-kicker { display: inline-block; font-size: 11px; color: #6b7280; background: #f3f4f6; border-radius: 999px; padding: 3px 10px; letter-spacing: .04em; }
.intake-card h2 { margin: 14px 0 6px; font-size: 18px; line-height: 1.5; color: #111827; }
.intake-option { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; padding: 16px 16px; border: 1px solid #e5e7eb; border-radius: 10px; background: #fff; color: #111827; font-size: 14px; text-align: left; cursor: pointer; }
.intake-option:hover { border-color: var(--brand, var(--accent)); background: #f8fafc; }
.intake-option span:last-child { color: #6b7280; font-size: 20px; line-height: 1; }
#intakeNameStep { margin-top: 4px; }
#intakeView { padding: 4px 0; }
.chat-image { display: block; width: 180px; max-width: 100%; border-radius: 8px; border: 1px solid #e5e7eb; margin: 0 0 8px; background: #fff; }
