/* ==========================================================================
   在线客服系统 · 后台样式
   ========================================================================== */

:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --surface-3: #f1f5fb;
    --border: #e7ecf4;
    --border-strong: #d8e0ec;
    --text: #0f172a;
    --text-2: #334155;
    --muted: #64748b;
    --muted-2: #94a3b8;
    --primary: #2563eb;
    --primary-600: #1d4ed8;
    --primary-soft: #eff6ff;
    --green: #10b981;
    --amber: #f59e0b;
    --red: #ef4444;
    --violet: #7c3aed;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 12px 32px rgba(15, 23, 42, 0.06);
    --shadow-lg: 0 24px 60px rgba(15, 23, 42, 0.12);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
    font-size: 14px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { flex: none; display: inline-block; vertical-align: middle; }
img { max-width: 100%; }
h1, h2, h3, h4, p { margin: 0; }
code, pre, .mono { font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace; }
::selection { background: #cfe0ff; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: #d5deea; border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: #b9c6d8; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- 基础组件 ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9px 15px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--text-2);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    transition: background .16s ease, border-color .16s ease, transform .16s ease, box-shadow .16s ease;
}
.btn svg { width: 16px; height: 16px; }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 8px 18px rgba(37, 99, 235, .22); }
.btn-primary:hover { background: var(--primary-600); }
.btn-ghost { background: #fff; border-color: var(--border); color: var(--text-2); }
.btn-ghost:hover { border-color: #c9d5e7; background: #fbfdff; }
.btn-block { width: 100%; }
.btn-lg { padding: 12px 20px; font-size: 14px; border-radius: 12px; }
.btn-sm { padding: 7px 11px; font-size: 12px; }
.btn-xs { padding: 4px 8px; font-size: 11px; border-radius: 8px; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.danger-text { color: var(--red) !important; }
.danger-text:hover { background: #fef2f2 !important; }
.danger-soft { color: var(--red); border-color: #fee2e2; background: #fff8f8; }
.danger-soft:hover { background: #fef2f2; }

.icon-btn {
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background .16s ease, color .16s ease;
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.soft { background: #fff; border: 1px solid var(--border); }
.icon-btn.soft:hover { border-color: #cdd9eb; background: #fbfdff; }
.icon-btn.tiny { width: 27px; height: 27px; border-radius: 8px; }
.icon-btn.tiny svg { width: 14px; height: 14px; }
.icon-btn.danger:hover { color: var(--red); background: #fef2f2; border-color: #fecaca; }
.link-button {
    border: 0;
    background: none;
    color: var(--primary);
    font-size: 12.5px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0;
}
.link-button svg { width: 14px; height: 14px; }
.link-button:hover { color: var(--primary-600); text-decoration: underline; }

input[type="text"], input[type="password"], input[type="search"], input[type="number"],
input[type="email"], input[type="url"], input[type="time"], textarea, select {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
    padding: 10px 12px;
    font-size: 13px;
    color: var(--text);
    outline: none;
    transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
input:focus, textarea:focus, select:focus {
    border-color: #93b4ff;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
input::placeholder, textarea::placeholder { color: #a7b3c6; }
textarea { resize: vertical; line-height: 1.65; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px; }
input[type="color"] { width: 44px; height: 36px; padding: 3px; border: 1px solid var(--border); border-radius: 9px; background: #fff; cursor: pointer; }
input[type="checkbox"] { accent-color: var(--primary); width: 16px; height: 16px; margin: 0; cursor: pointer; }

.avatar {
    --avatar: #2563eb;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--avatar);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .3px;
    flex: none;
    user-select: none;
}
.avatar-sm { width: 32px; height: 32px; font-size: 11px; }
.avatar-xs { width: 24px; height: 24px; font-size: 9px; }
.avatar-md { width: 44px; height: 44px; font-size: 13px; }
.avatar-lg { width: 58px; height: 58px; font-size: 17px; }

.tag {
    display: inline-flex;
    align-items: center;
    padding: 2px 7px;
    border-radius: 6px;
    background: #f1f5f9;
    color: #64748b;
    font-size: 10.5px;
    font-weight: 600;
    line-height: 1.6;
    white-space: nowrap;
}
.tag-blue { background: #eaf2ff; color: #2563eb; }
.tag-green { background: #e8fbf3; color: #059669; }
.tag-amber { background: #fff7e8; color: #b45309; }
.tag-violet { background: #f3edff; color: #7c3aed; }
.tag-gray { background: #f1f5f9; color: #64748b; }
.muted { color: var(--muted); }
.small { font-size: 11.5px; }
.break { word-break: break-all; }
.nowrap { white-space: nowrap; }
.align-right { text-align: right; }
.mono { font-size: 12px; color: var(--text-2); }

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 10.5px;
    font-weight: 600;
    background: #f1f5f9;
    color: #64748b;
    white-space: nowrap;
}
.status-pill.open { background: #e8fbf3; color: #059669; }
.status-pill.closed { background: #f1f5f9; color: #64748b; }
.status-pill.sent { background: #e8fbf3; color: #059669; }
.status-pill.pending { background: #fff7e8; color: #b45309; }
.status-pill.sending { background: #eaf2ff; color: #2563eb; }
.status-pill.failed { background: #fef2f2; color: #dc2626; }

.online-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: #059669;
    font-weight: 600;
}
.online-pill i { width: 6px; height: 6px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, .12); }
.online-pill.offline { color: #94a3b8; }
.online-pill.offline i { background: #cbd5e1; box-shadow: none; }

/* ---------- 应用框架 ---------- */
.app-shell { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }
.rail {
    width: 72px;
    flex: none;
    background: #fff;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 14px 0 16px;
    z-index: 30;
}
.rail-logo {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, #4f8bff, #1d4ed8);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 18px;
    letter-spacing: -.5px;
    box-shadow: 0 8px 18px rgba(37, 99, 235, .28);
}
.rail-nav { display: flex; flex-direction: column; gap: 4px; margin-top: 18px; flex: 1; }
.rail-link {
    position: relative;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    transition: background .16s ease, color .16s ease;
}
.rail-link svg { width: 20px; height: 20px; }
.rail-link:hover { background: #f4f7fb; color: var(--text); }
.rail-link.active { background: var(--primary-soft); color: var(--primary); }
.rail-link.active::before {
    content: "";
    position: absolute;
    left: -14px;
    top: 12px;
    bottom: 12px;
    width: 3px;
    border-radius: 0 4px 4px 0;
    background: var(--primary);
}
.rail-tip {
    position: absolute;
    left: 54px;
    top: 50%;
    transform: translateY(-50%) translateX(-4px);
    background: #0f172a;
    color: #fff;
    font-size: 11.5px;
    font-weight: 500;
    padding: 5px 9px;
    border-radius: 7px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity .14s ease, transform .14s ease;
    z-index: 80;
    box-shadow: 0 8px 20px rgba(15, 23, 42, .2);
}
.rail-link:hover .rail-tip { opacity: 1; transform: translateY(-50%) translateX(0); }
.rail-badge {
    position: absolute;
    top: 3px;
    right: 2px;
    min-width: 17px;
    height: 17px;
    border-radius: 999px;
    background: var(--red);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid #fff;
}
.rail-bottom { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.rail-user {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--avatar, #2563eb);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    margin-top: 3px;
    box-shadow: 0 0 0 3px #f1f5f9;
}
.rail-logout { margin: 0; }
.rail-button { border: 0; background: transparent; padding: 0; }

.app-main { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.topbar {
    height: 64px;
    flex: none;
    background: #fff;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 22px;
    gap: 16px;
    z-index: 20;
}
.topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.menu-btn { display: none; }
.home-link {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
}
.home-link svg { width: 18px; height: 18px; }
.home-link:hover { background: var(--surface-3); color: var(--text); }
.crumb-sep { color: #cbd5e1; display: flex; }
.crumb-sep svg { width: 15px; height: 15px; }
.topbar-title { font-size: 16px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { display: flex; align-items: center; gap: 12px; }

.lang-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border-radius: 999px;
    background: #fff6ed;
    color: #ea580c;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid #ffedd5;
    white-space: nowrap;
}
.lang-pill svg { width: 13px; height: 13px; }

.user-menu { position: relative; }
.user-button {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 4px 6px 4px 4px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    text-align: left;
}
.user-button:hover { background: #f7fafc; }
.user-button > svg { width: 14px; height: 14px; color: var(--muted-2); }
.user-meta { display: flex; flex-direction: column; line-height: 1.25; }
.user-meta strong { font-size: 12.5px; font-weight: 700; }
.user-meta small { font-size: 10px; color: var(--muted-2); }
.user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 218px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow-lg);
    padding: 6px;
    z-index: 100;
}
.user-dropdown-head { display: flex; align-items: center; gap: 10px; padding: 10px; border-bottom: 1px solid #f1f5f9; margin-bottom: 4px; }
.user-dropdown-head div { display: flex; flex-direction: column; min-width: 0; }
.user-dropdown-head strong { font-size: 12.5px; }
.user-dropdown-head small { color: var(--muted-2); font-size: 11px; }
.dropdown-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 10px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text-2);
    font-size: 12.5px;
    text-align: left;
}
.dropdown-item svg { width: 15px; height: 15px; color: var(--muted); }
.dropdown-item:hover { background: #f5f8fc; }
.dropdown-item.danger { color: var(--red); }
.dropdown-item.danger svg { color: var(--red); }

.identity-switch {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 4px 4px 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    position: relative;
}
.identity-label { font-size: 10px; color: var(--muted-2); white-space: nowrap; }
.identity-button {
    display: flex;
    align-items: center;
    gap: 6px;
    border: 0;
    background: #f8fafc;
    border-radius: 8px;
    padding: 6px 9px;
    font-size: 11.5px;
    max-width: 190px;
}
.identity-button > svg { width: 12px; height: 12px; color: var(--muted-2); }
.identity-dot { width: 6px; height: 6px; border-radius: 50%; background: #22c55e; }
.identity-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.identity-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 230px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 6px;
    z-index: 110;
    max-height: 320px;
    overflow-y: auto;
}
.identity-option {
    width: 100%;
    border: 0;
    background: transparent;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px;
    border-radius: 8px;
    text-align: left;
}
.identity-option:hover { background: #f5f8fc; }
.identity-option.active { background: var(--primary-soft); }
.identity-option div { display: flex; flex-direction: column; }
.identity-option strong { font-size: 12px; }
.identity-option small { font-size: 10px; color: var(--muted-2); }

.flash-stack {
    position: fixed;
    top: 76px;
    right: 22px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 9px;
    max-width: 380px;
}
.flash {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 11px 13px;
    box-shadow: var(--shadow-lg);
    font-size: 12.5px;
    color: var(--text-2);
    animation: slideIn .22s ease;
}
.flash svg { width: 16px; height: 16px; margin-top: 1px; }
.flash-success { border-color: #bbf7d0; }
.flash-success > svg { color: #16a34a; }
.flash-error { border-color: #fecaca; }
.flash-error > svg { color: #dc2626; }
.flash-close { margin-left: auto; border: 0; background: none; color: var(--muted-2); padding: 0 2px; }
@keyframes slideIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

.workspace-main { flex: 1; min-height: 0; display: flex; }
.page-main { flex: 1; min-height: 0; overflow-y: auto; }

/* ---------- 工作台 ---------- */
.workspace { display: grid; grid-template-columns: 360px minmax(0, 1fr); width: 100%; height: 100%; min-height: 0; }
.conv-panel {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    background: #fff;
    border-right: 1px solid var(--border);
}
.conv-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 18px 12px; }
.conv-head-title { display: flex; align-items: center; gap: 9px; }
.conv-head h2 { font-size: 19px; font-weight: 800; letter-spacing: -.3px; }
.count-pill { background: #eef5ff; color: var(--primary); font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }

.conv-search { position: relative; margin: 0 18px 12px; }
.conv-search > svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--muted-2); pointer-events: none; }
.conv-search input { padding: 9px 12px 9px 35px; background: #f8fafc; border-color: #eef2f8; font-size: 12.5px; border-radius: 10px; }
.conv-search input:focus { background: #fff; }

.conv-filters { padding: 0 18px 13px; border-bottom: 1px solid #f1f5f9; }
.filter-caption { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--muted-2); margin-bottom: 7px; }
.filter-caption svg { width: 12px; height: 12px; }
.filter-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mini-field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.mini-field > span { font-size: 10px; color: var(--muted-2); padding-left: 1px; }
.mini-field select { padding: 7px 24px 7px 8px; font-size: 11.5px; border-color: #eef2f8; border-radius: 8px; background-color: #fbfdff; }

.conv-tabs { display: flex; gap: 2px; padding: 9px 13px 0; border-bottom: 1px solid #f1f5f9; }
.conv-tab { position: relative; border: 0; background: none; padding: 7px 9px 9px; font-size: 12px; color: var(--muted); border-bottom: 2px solid transparent; }
.conv-tab:hover { color: var(--text); }
.conv-tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 700; }
.tab-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 16px; height: 16px; border-radius: 999px; background: var(--red); color: #fff; font-size: 9px; padding: 0 4px; margin-left: 2px; }

.conv-list { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.conv-item {
    display: flex;
    gap: 10px;
    padding: 13px 16px;
    border-bottom: 1px solid #f3f6fa;
    cursor: pointer;
    position: relative;
    transition: background .14s ease;
}
.conv-item:hover { background: #fafcff; }
.conv-item.active { background: #eff6ff; }
.conv-item.active::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--primary); }
.conv-avatar { position: relative; flex: none; }
.conv-avatar .avatar { width: 42px; height: 42px; }
.conv-unread {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 18px;
    height: 18px;
    border-radius: 999px;
    background: var(--red);
    color: #fff;
    border: 2px solid #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 700;
    padding: 0 4px;
}
.conv-main { flex: 1; min-width: 0; }
.conv-line1 { display: flex; align-items: center; gap: 6px; }
.conv-name { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.conv-time { font-size: 10px; color: var(--muted-2); white-space: nowrap; }
.conv-tags { display: flex; align-items: center; gap: 4px; margin: 3px 0 3px; min-height: 17px; overflow: hidden; }
.conv-preview { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reply-state { color: #d97706; font-size: 9.5px; font-weight: 700; white-space: nowrap; }
.conv-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 5px; font-size: 10px; color: var(--muted-2); }
.conv-foot-left { display: flex; align-items: center; gap: 5px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot { width: 5px; height: 5px; border-radius: 50%; background: #cbd5e1; display: inline-block; flex: none; }
.dot.online { background: #22c55e; box-shadow: 0 0 0 2px rgba(34, 197, 94, .14); }
.conv-count { background: #f1f5f9; border-radius: 5px; padding: 1px 5px; color: #64748b; font-size: 9.5px; }

.conv-footer { flex: none; padding: 9px 16px; border-top: 1px solid #f1f5f9; display: flex; align-items: center; justify-content: space-between; font-size: 11px; color: var(--muted-2); min-height: 38px; }
.conv-skeleton { padding: 8px 16px; }
.skeleton-row { display: flex; gap: 11px; padding: 13px 0; border-bottom: 1px solid #f3f6fa; }
.sk-avatar { width: 42px; height: 42px; border-radius: 50%; background: #eef2f8; animation: pulse 1.2s infinite; }
.sk-lines { flex: 1; display: flex; flex-direction: column; gap: 7px; padding-top: 3px; }
.sk-lines span { height: 9px; border-radius: 5px; background: #eef2f8; animation: pulse 1.2s infinite; }
.sk-lines span:nth-child(2) { width: 66%; }
.sk-lines span:nth-child(3) { width: 45%; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }

.chat-panel { position: relative; display: flex; min-width: 0; min-height: 0; background: #f6f8fc; overflow: hidden; }
.chat-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 40px 24px; }
.empty-illustration {
    width: 86px;
    height: 86px;
    border-radius: 26px;
    background: #eaf2ff;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    margin-bottom: 24px;
    color: var(--primary);
}
.empty-illustration > svg { width: 36px; height: 36px; }
.empty-ring { position: absolute; inset: -12px; border: 1px dashed #dbe7ff; border-radius: 34px; }
.chat-empty h2 { font-size: 21px; font-weight: 800; margin-bottom: 9px; letter-spacing: -.3px; }
.chat-empty p { font-size: 13px; color: var(--muted); line-height: 1.85; margin-bottom: 20px; }
.ready-pill { display: inline-flex; align-items: center; gap: 7px; background: #fff; border: 1px solid #e9eff8; border-radius: 999px; padding: 7px 14px; font-size: 11px; color: var(--muted); box-shadow: 0 4px 14px rgba(15, 23, 42, .04); }
.ready-pill i { width: 7px; height: 7px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, .14); }

.chat-active { display: flex; flex-direction: column; width: 100%; height: 100%; min-height: 0; }
.chat-head {
    flex: none;
    min-height: 72px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 18px;
}
.back-button { display: none; }
.chat-identity { flex: 1; min-width: 0; }
.chat-name-line { display: flex; align-items: center; gap: 9px; min-width: 0; }
.chat-name-line h3 { font-size: 15px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.online-line { display: inline-flex; align-items: center; gap: 5px; font-size: 10.5px; color: var(--muted-2); white-space: nowrap; }
.online-line i { width: 6px; height: 6px; border-radius: 50%; background: #cbd5e1; }
.online-line.online { color: #059669; }
.online-line.online i { background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, .12); }
.chat-tags { display: flex; align-items: center; gap: 5px; margin-top: 3px; overflow: hidden; }
.chat-actions { display: flex; align-items: center; gap: 6px; }
.soft-button {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 9px;
    padding: 7px 10px;
    font-size: 11.5px;
    color: var(--text-2);
    white-space: nowrap;
}
.soft-button svg { width: 14px; height: 14px; color: var(--muted); }
.soft-button:hover { background: #fafcff; border-color: #cdd9eb; }
.action-wrap { position: relative; }
.popover {
    position: absolute;
    top: calc(100% + 7px);
    right: 0;
    min-width: 190px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 5px;
    z-index: 60;
    max-height: 330px;
    overflow-y: auto;
}
.popover button {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 9px;
    border: 0;
    background: transparent;
    border-radius: 8px;
    text-align: left;
    font-size: 12px;
    color: var(--text-2);
}
.popover button:hover { background: #f5f8fc; }
.popover button.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.popover .popover-title { padding: 6px 9px 4px; font-size: 10px; color: var(--muted-2); text-transform: uppercase; letter-spacing: .4px; }
.popover button svg { width: 14px; height: 14px; }

.chat-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.messages { max-width: 980px; margin: 0 auto; padding: 24px 26px 18px; }
.message-row { display: flex; gap: 9px; margin-bottom: 15px; align-items: flex-start; }
.message-row.mine { flex-direction: row-reverse; }
.msg-avatar { width: 31px; height: 31px; border-radius: 50%; background: #e2e8f0; color: #475569; display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 700; flex: none; margin-top: 2px; }
.msg-content { max-width: min(68%, 700px); display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.mine .msg-content { align-items: flex-end; }
.msg-meta { display: flex; align-items: center; gap: 6px; font-size: 10px; color: var(--muted-2); padding: 0 2px; }
.msg-bubble {
    background: #fff;
    border: 1px solid #e9eef7;
    border-radius: 3px 13px 13px 13px;
    padding: 9px 12px;
    color: #1e293b;
    font-size: 13px;
    line-height: 1.68;
    white-space: pre-wrap;
    word-break: break-word;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .025);
}
.mine .msg-bubble {
    background: linear-gradient(135deg, #3273ff, #2563eb);
    border-color: transparent;
    color: #fff;
    border-radius: 13px 3px 13px 13px;
    box-shadow: 0 7px 16px rgba(37, 99, 235, .18);
}
.msg-bubble.bot { background: #f3f8ff; border-color: #dbeafe; }
.msg-bubble img { display: block; max-width: 260px; max-height: 260px; border-radius: 9px; cursor: zoom-in; }
.mine .msg-bubble img { max-width: 240px; }
.msg-bubble a { color: #2563eb; text-decoration: underline; }
.mine .msg-bubble a { color: #dbeafe; }
.message-row.system-row { justify-content: center; margin: 12px 0; }
.system-pill { background: #edf1f7; color: #64748b; font-size: 10.5px; padding: 4px 10px; border-radius: 999px; text-align: center; max-width: 80%; }
.date-divider { display: flex; align-items: center; justify-content: center; margin: 20px 0 16px; }
.date-divider span { background: #e9eef6; color: #7c8ba1; font-size: 10px; padding: 3px 9px; border-radius: 999px; }
.typing-line { display: flex; align-items: center; gap: 3px; padding: 0 26px 12px; font-size: 10px; color: var(--muted-2); }
.typing-line span { width: 4px; height: 4px; border-radius: 50%; background: #94a3b8; animation: typing 1.1s infinite; }
.typing-line span:nth-child(2) { animation-delay: .15s; }
.typing-line span:nth-child(3) { animation-delay: .3s; }
@keyframes typing { 0%, 60%, 100% { transform: translateY(0); opacity: .4; } 30% { transform: translateY(-3px); opacity: 1; } }

.closed-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: #fff8ef;
    border-top: 1px solid #ffedd5;
    padding: 9px 18px;
    font-size: 12px;
    color: #9a3412;
}
.closed-banner > div { display: flex; align-items: center; gap: 7px; }
.closed-banner svg { width: 15px; height: 15px; }

.composer { position: relative; flex: none; background: #fff; border-top: 1px solid var(--border); padding: 8px 18px 12px; }
.composer-tools { display: flex; align-items: center; gap: 3px; }
.tool-button {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: 0;
    background: transparent;
    color: var(--muted);
    border-radius: 7px;
    padding: 5px 7px;
    font-size: 11.5px;
}
.tool-button svg { width: 17px; height: 17px; }
.tool-button:hover { background: #f4f7fb; color: var(--text); }
.tool-button.sound-off { opacity: .45; }
.messages-empty { padding: 30px 0; }
.toolbar-spacer { flex: 1; }
.composer-tip { font-size: 10px; color: #b0bccd; }
.composer textarea {
    width: 100%;
    min-height: 58px;
    max-height: 150px;
    border: 0;
    background: transparent;
    padding: 6px 4px 2px;
    resize: none;
    font-size: 13.5px;
    line-height: 1.7;
    box-shadow: none;
}
.composer textarea:focus { box-shadow: none; }
.composer-bottom { display: flex; align-items: center; justify-content: flex-end; gap: 12px; }
.composer-count { font-size: 10px; color: #b0bccd; margin-right: auto; }
.send-button { padding: 8px 17px; border-radius: 9px; }
.send-button svg { width: 15px; height: 15px; }
.emoji-panel {
    position: absolute;
    bottom: calc(100% - 2px);
    left: 16px;
    width: 294px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 13px;
    box-shadow: var(--shadow-lg);
    padding: 9px;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
    z-index: 50;
}
.emoji-panel button { border: 0; background: transparent; font-size: 19px; line-height: 1; padding: 5px; border-radius: 7px; }
.emoji-panel button:hover { background: #f2f6fc; }
.quick-panel {
    position: absolute;
    bottom: calc(100% - 2px);
    left: 16px;
    width: 340px;
    max-height: 360px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 13px;
    box-shadow: var(--shadow-lg);
    z-index: 50;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid #f1f5f9; font-size: 12px; }
.panel-close { border: 0; background: none; color: var(--muted); padding: 2px; }
.panel-close svg { width: 14px; height: 14px; }
.quick-list { overflow-y: auto; padding: 6px; }
.quick-item { width: 100%; border: 0; background: transparent; border-radius: 8px; padding: 8px 9px; text-align: left; display: flex; flex-direction: column; gap: 2px; }
.quick-item:hover { background: #f5f8fc; }
.quick-item strong { font-size: 11.5px; }
.quick-item span { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.uploading-mask { position: absolute; inset: 0; background: rgba(255, 255, 255, .88); display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 12px; color: var(--muted); z-index: 30; }
.spinner { width: 16px; height: 16px; border: 2px solid #dbeafe; border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

.info-panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 330px;
    background: #fff;
    border-left: 1px solid var(--border);
    box-shadow: -18px 0 40px rgba(15, 23, 42, .06);
    z-index: 40;
    overflow-y: auto;
    padding: 16px 18px 24px;
    animation: slideLeft .2s ease;
}
@keyframes slideLeft { from { transform: translateX(16px); opacity: 0; } to { transform: none; opacity: 1; } }
.info-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.info-head h3 { font-size: 15px; font-weight: 800; }
.info-profile { display: flex; align-items: center; gap: 12px; padding-bottom: 16px; border-bottom: 1px solid #f1f5f9; }
.info-profile div { display: flex; flex-direction: column; min-width: 0; }
.info-profile strong { font-size: 14px; }
.info-profile span { font-size: 11px; color: var(--muted); }
.info-section { padding-top: 16px; }
.info-section h4 { font-size: 10px; color: var(--muted-2); letter-spacing: .6px; text-transform: uppercase; margin-bottom: 9px; }
.info-list { display: grid; grid-template-columns: 72px 1fr; gap: 7px 8px; margin: 0; font-size: 11.5px; }
.info-list dt { color: var(--muted-2); }
.info-list dd { margin: 0; color: var(--text-2); word-break: break-word; }
.info-section textarea { font-size: 12px; margin-bottom: 8px; }

/* ---------- 页面通用 ---------- */
.page-wrap { max-width: 1240px; margin: 0 auto; padding: 26px 30px 54px; }
.page-wrap.narrow { max-width: 920px; }
.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.eyebrow { font-size: 10px; font-weight: 700; color: var(--primary); letter-spacing: 1.2px; text-transform: uppercase; margin-bottom: 4px; }
.page-heading h1 { font-size: 25px; font-weight: 800; letter-spacing: -.5px; }
.page-subtitle { color: var(--muted); font-size: 12.5px; margin-top: 5px; max-width: 660px; }
.heading-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.back-link { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; color: var(--muted); margin-bottom: 6px; }
.back-link svg { width: 14px; height: 14px; }
.back-link:hover { color: var(--primary); }

.card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 1px 2px rgba(15, 23, 42, .02); }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 18px 20px 14px; }
.card-head h2 { font-size: 15px; font-weight: 800; }
.card-head p { font-size: 11.5px; color: var(--muted-2); margin-top: 2px; }
.head-icon { width: 20px; height: 20px; color: #cbd5e1; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.stat-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 17px 18px; display: flex; align-items: flex-start; gap: 12px; }
.stat-icon { width: 38px; height: 38px; border-radius: 11px; display: flex; align-items: center; justify-content: center; flex: none; }
.stat-icon svg { width: 18px; height: 18px; }
.stat-icon.blue { background: #eaf2ff; color: #2563eb; }
.stat-icon.violet { background: #f3edff; color: #7c3aed; }
.stat-icon.amber { background: #fff7e8; color: #d97706; }
.stat-icon.green { background: #e8fbf3; color: #059669; }
.stat-body { display: flex; flex-direction: column; min-width: 0; }
.stat-body span { font-size: 11.5px; color: var(--muted); }
.stat-body strong { font-size: 26px; line-height: 1.2; font-weight: 800; letter-spacing: -.8px; margin: 2px 0; }
.stat-body small { font-size: 10px; color: var(--muted-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(290px, 1fr); gap: 16px; margin-bottom: 16px; }
.dashboard-grid.lower { grid-template-columns: minmax(0, 1.5fr) minmax(300px, 1fr); }
.chart-card .card-head { padding-bottom: 6px; }
.legend { display: flex; align-items: center; gap: 4px; font-size: 10px; color: var(--muted); }
.legend .dot { width: 6px; height: 6px; border-radius: 2px; margin-left: 6px; }
.legend .dot.blue { background: #2563eb; }
.legend .dot.light { background: #c7dbff; }
.bar-chart { height: 235px; display: flex; align-items: flex-end; justify-content: space-around; gap: 8px; padding: 18px 22px 16px; }
.bar-group { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; justify-content: flex-end; min-width: 0; }
.bar-pair { display: flex; align-items: flex-end; justify-content: center; gap: 4px; height: 100%; width: 100%; }
.bar { width: 12px; border-radius: 4px 4px 2px 2px; min-height: 2px; transition: height .3s ease; }
.bar-conv { background: #2563eb; }
.bar-msg { background: #c7dbff; }
.bar-label { display: flex; flex-direction: column; align-items: center; font-size: 9.5px; color: var(--muted-2); white-space: nowrap; }
.bar-label small { font-size: 8.5px; color: #b6c2d4; }
.side-card { display: flex; flex-direction: column; }
.agent-list { list-style: none; margin: 0; padding: 0 18px; display: flex; flex-direction: column; gap: 9px; }
.agent-list li { display: flex; align-items: center; gap: 9px; }
.agent-list li div { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.agent-list strong { font-size: 12px; }
.agent-list small { font-size: 10px; color: var(--muted-2); }
.side-metrics { margin-top: auto; border-top: 1px solid #f1f5f9; display: grid; grid-template-columns: 1fr 1fr; }
.side-metrics > div { padding: 11px 18px; border-bottom: 1px solid #f6f8fb; display: flex; flex-direction: column; gap: 1px; }
.side-metrics > div:nth-child(odd) { border-right: 1px solid #f6f8fb; }
.side-metrics span { font-size: 10px; color: var(--muted-2); }
.side-metrics strong { font-size: 14px; font-weight: 800; }
.mini-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 30px 20px; text-align: center; color: var(--muted-2); gap: 6px; }
.mini-empty svg { width: 26px; height: 26px; color: #cbd5e1; }
.mini-empty p { font-size: 12px; }
.mini-empty a { font-size: 11.5px; color: var(--primary); font-weight: 600; }

.table-wrap { width: 100%; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.data-table th { text-align: left; font-size: 10px; font-weight: 600; color: var(--muted-2); padding: 10px 14px; background: #fbfcfe; border-top: 1px solid #f1f5f9; border-bottom: 1px solid #f1f5f9; white-space: nowrap; }
.data-table td { padding: 11px 14px; border-bottom: 1px solid #f4f7fb; vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #fbfdff; }
.data-table th:first-child, .data-table td:first-child { padding-left: 20px; }
.data-table th:last-child, .data-table td:last-child { padding-right: 20px; }
.row-link { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; color: var(--text); }
.row-link:hover { color: var(--primary); }
.preview-cell { max-width: 250px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.cell-sub { color: var(--muted-2); font-size: 10.5px; margin-top: 2px; max-width: 330px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-cell { display: flex; align-items: center; gap: 9px; }
.person-cell div { display: flex; flex-direction: column; }
.person-cell strong { font-size: 12px; }
.person-cell small { font-size: 10px; color: var(--muted-2); }
.row-actions { display: inline-flex; align-items: center; gap: 4px; }
.row-actions form { display: inline-flex; }
.inline-form { display: inline-flex; margin: 0; }

.reply-rank { list-style: none; margin: 0; padding: 0 18px 16px; }
.reply-rank li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid #f4f7fb; }
.reply-rank li:last-child { border-bottom: 0; }
.rank-index { width: 20px; height: 20px; border-radius: 6px; background: #f1f5f9; color: #64748b; display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 700; flex: none; }
.reply-rank li:nth-child(1) .rank-index { background: #fff1d6; color: #b45309; }
.reply-rank div { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.reply-rank strong { font-size: 12px; }
.reply-rank small { font-size: 10px; color: var(--muted-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-count { font-size: 10px; color: var(--muted); }

.toolbar { display: flex; align-items: center; gap: 8px; padding: 14px 18px; border-bottom: 1px solid #f1f5f9; flex-wrap: wrap; }
.toolbar-search { position: relative; flex: 1; min-width: 200px; max-width: 420px; }
.toolbar-search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--muted-2); }
.toolbar-search input { padding-left: 34px; background: #fbfcfe; }
.toolbar-select { width: auto; min-width: 130px; padding: 9px 30px 9px 11px; }
.toolbar .btn { flex: none; }

.switch { position: relative; width: 34px; height: 20px; border: 0; border-radius: 999px; background: #dbe3ee; padding: 0; transition: background .18s ease; }
.switch span { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(15, 23, 42, .2); transition: transform .18s ease; }
.switch.on { background: var(--primary); }
.switch.on span { transform: translateX(14px); }
.keyword-chip { display: inline-block; background: #f5f8fc; border: 1px solid #eef2f8; border-radius: 6px; padding: 2px 7px; font-size: 11px; color: var(--text-2); max-width: 210px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.empty-block { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 58px 24px; gap: 7px; }
.empty-block.compact { padding: 34px 20px; }
.empty-icon { width: 52px; height: 52px; border-radius: 15px; background: #f1f6ff; color: var(--primary); display: flex; align-items: center; justify-content: center; margin-bottom: 4px; }
.empty-icon svg { width: 23px; height: 23px; }
.empty-block h3 { font-size: 15px; font-weight: 800; }
.empty-block p { font-size: 12px; color: var(--muted); max-width: 380px; line-height: 1.7; }
.empty-block .btn { margin-top: 8px; }

.tips-card { display: flex; gap: 10px; margin-top: 14px; padding: 13px 16px; background: #f8fbff; border: 1px solid #e6eefb; border-radius: 12px; color: var(--muted); }
.tips-card > div:first-child { width: 28px; height: 28px; border-radius: 8px; background: #eaf2ff; color: var(--primary); display: flex; align-items: center; justify-content: center; flex: none; }
.tips-card svg { width: 15px; height: 15px; }
.tips-card strong { font-size: 11.5px; color: var(--text-2); display: block; margin-bottom: 2px; }
.tips-card p { font-size: 11px; line-height: 1.7; }
.tips-card code { background: #eef4ff; padding: 1px 4px; border-radius: 4px; }

/* ---------- 表单 ---------- */
.form-card { padding: 4px 22px 22px; }
.form-section { padding: 20px 0; border-bottom: 1px solid #f1f5f9; }
.form-section:last-of-type { border-bottom: 0; }
.form-section-head { margin-bottom: 14px; }
.form-section-head h2 { font-size: 14px; font-weight: 800; }
.form-section-head p { font-size: 11px; color: var(--muted-2); margin-top: 2px; }
.form-grid { display: grid; gap: 13px; margin-bottom: 13px; }
.form-grid.two { grid-template-columns: 1fr 1fr; }
.form-grid.three { grid-template-columns: 1fr 1fr 1fr; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span { font-size: 11.5px; font-weight: 600; color: var(--text-2); display: flex; align-items: center; gap: 5px; }
.field > span em { color: var(--red); font-style: normal; }
.field > span small { font-weight: 400; color: var(--muted-2); font-size: 10px; }
.field-hint { font-size: 10px; color: var(--muted-2); line-height: 1.5; }
.field-action { justify-content: flex-end; }
.field-action .btn { width: fit-content; }
.switch-group { display: flex; flex-direction: column; gap: 9px; justify-content: center; }
.switch-group.horizontal { flex-direction: row; flex-wrap: wrap; gap: 18px; margin-top: 6px; }
.compact-group { justify-content: flex-end; }
.check-line { display: flex; align-items: flex-start; gap: 9px; cursor: pointer; padding: 2px 0; }
.check-line input { margin-top: 2px; }
.check-line > span { display: flex; flex-direction: column; gap: 1px; }
.check-line strong { font-size: 12px; font-weight: 600; }
.check-line small { font-size: 10px; color: var(--muted-2); }
.check-line.standalone { padding: 11px 12px; background: #fbfcfe; border: 1px solid #f1f5f9; border-radius: 10px; margin-bottom: 14px; }
.form-actions { display: flex; align-items: center; justify-content: flex-end; gap: 9px; padding-top: 18px; margin-top: 4px; border-top: 1px solid #f1f5f9; }
.form-actions.compact { border: 0; padding-top: 8px; }
.form-grid .field textarea { min-height: 76px; }
.color-input { display: flex; align-items: center; gap: 9px; }
.color-input span { font-size: 11px; color: var(--muted); font-family: monospace; }
.day-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.day-pill { position: relative; cursor: pointer; }
.day-pill input { position: absolute; opacity: 0; pointer-events: none; }
.day-pill span { display: inline-flex; padding: 6px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 11.5px; color: var(--muted); background: #fff; }
.day-pill input:checked + span { background: var(--primary-soft); border-color: #bfd5ff; color: var(--primary); font-weight: 600; }

/* ---------- 快捷语 ---------- */
.split-layout { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 16px; align-items: start; }
.sticky-card { position: sticky; top: 18px; }
.quick-admin-list { list-style: none; margin: 0; padding: 0 18px 16px; }
.quick-admin-list li { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; border-bottom: 1px solid #f4f7fb; }
.quick-admin-list li:last-child { border-bottom: 0; }
.quick-admin-list li.editing { background: #fbfdff; margin: 0 -8px; padding: 12px 8px; border-radius: 8px; }
.quick-admin-main { flex: 1; min-width: 0; }
.quick-admin-main strong { font-size: 12.5px; }
.quick-admin-main p { font-size: 11.5px; color: var(--muted); margin-top: 3px; line-height: 1.6; }

/* ---------- 商户 ---------- */
.merchant-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.merchant-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 13px; }
.merchant-head { display: flex; align-items: flex-start; gap: 11px; }
.merchant-logo { width: 40px; height: 40px; border-radius: 11px; background: color-mix(in srgb, var(--merchant, #2563eb) 12%, white); color: var(--merchant, #2563eb); display: flex; align-items: center; justify-content: center; flex: none; }
.merchant-logo svg { width: 19px; height: 19px; }
.merchant-title { min-width: 0; }
.merchant-title h2 { font-size: 15px; font-weight: 800; }
.merchant-meta { display: flex; align-items: center; gap: 6px; margin-top: 3px; flex-wrap: wrap; font-size: 10.5px; }
.merchant-key { display: flex; align-items: center; gap: 8px; background: #f8fafc; border: 1px solid #f1f5f9; border-radius: 9px; padding: 7px 9px; }
.merchant-key > span { font-size: 10px; color: var(--muted-2); white-space: nowrap; }
.merchant-key code { flex: 1; min-width: 0; font-size: 10.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; }
.embed-box { background: #0f172a; border-radius: 10px; padding: 9px 11px; overflow: hidden; }
.embed-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.embed-head span { font-size: 9.5px; color: #94a3b8; }
.embed-head .link-button { color: #93c5fd; font-size: 10px; }
.embed-code { display: block; font-size: 9.5px; color: #cbd5e1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.merchant-actions { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; margin-top: auto; }
.merchant-actions form { display: inline-flex; }

/* ---------- 通知 ---------- */
.mini-stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 14px; }
.mini-stat { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; }
.mini-stat span { font-size: 11px; color: var(--muted); }
.mini-stat strong { font-size: 19px; font-weight: 800; }
.mini-stat strong.green { color: #059669; }
.mini-stat strong.amber { color: #d97706; }
.mini-stat strong.red { color: #dc2626; }
.alert-strip { display: flex; gap: 10px; border-radius: 12px; padding: 12px 14px; margin-bottom: 14px; font-size: 11.5px; }
.alert-strip.warning { background: #fffaf0; border: 1px solid #fde9c8; color: #92400e; }
.alert-strip svg { width: 17px; height: 17px; flex: none; margin-top: 1px; }
.alert-strip strong { display: block; font-size: 12px; }
.alert-strip p { color: #a16207; margin-top: 2px; }
.alert-strip a { text-decoration: underline; font-weight: 600; }
.notification-table td { vertical-align: top; }
.notification-content { min-width: 230px; max-width: 430px; }
.notification-content strong { font-size: 11.5px; }
.notification-content details { margin-top: 2px; }
.notification-content summary { font-size: 10px; color: var(--muted-2); cursor: pointer; }
.notification-content pre { white-space: pre-wrap; word-break: break-word; background: #f8fafc; border: 1px solid #f1f5f9; border-radius: 8px; padding: 8px; font-size: 10px; color: var(--muted); margin: 5px 0 0; max-height: 180px; overflow: auto; }
.error-text { font-size: 10px; color: #dc2626; margin-top: 4px; word-break: break-all; }
.clear-sent-form { padding: 0 18px 10px; display: flex; justify-content: flex-end; }
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 18px; border-top: 1px solid #f1f5f9; font-size: 11px; color: var(--muted); }
.pagination-links { display: flex; gap: 5px; }
.page-link { padding: 5px 10px; border: 1px solid var(--border); border-radius: 7px; background: #fff; font-size: 11px; }
.page-link:hover { border-color: #c9d5e7; }

/* ---------- 设置 ---------- */
.settings-card { padding: 0 22px 20px; margin-bottom: 16px; }
.settings-card .card-head { padding-left: 0; padding-right: 0; }
.settings-card .form-grid:last-child { margin-bottom: 0; }
.event-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.event-option { display: flex; align-items: flex-start; gap: 8px; border: 1px solid #eef2f8; border-radius: 9px; padding: 9px 10px; cursor: pointer; background: #fbfcfe; }
.event-option:has(input:checked) { border-color: #bfd5ff; background: #f5f9ff; }
.event-option > span { display: flex; flex-direction: column; gap: 1px; }
.event-option strong { font-size: 11px; }
.event-option small { font-size: 9.5px; color: var(--muted-2); line-height: 1.45; }
.cleanup-status { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: #fbfcfe; border: 1px solid #f1f5f9; border-radius: 10px; padding: 10px 12px; margin-top: 4px; }
.cleanup-status > div { display: flex; flex-direction: column; gap: 1px; }
.cleanup-status span { font-size: 10px; color: var(--muted-2); }
.cleanup-status strong { font-size: 11.5px; }
.cleanup-status small { font-size: 10px; color: var(--muted); }
.save-bar { position: sticky; bottom: 0; z-index: 15; display: flex; align-items: center; justify-content: space-between; gap: 14px; background: rgba(255, 255, 255, .94); backdrop-filter: blur(8px); border: 1px solid var(--border); border-radius: 13px; padding: 10px 14px; box-shadow: 0 -6px 24px rgba(15, 23, 42, .06); margin: 16px 0 22px; }
.save-bar > span { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.save-bar svg { width: 14px; height: 14px; }
.group-manage { display: flex; flex-direction: column; gap: 10px; }
.group-list { display: flex; flex-direction: column; gap: 5px; }
.group-row { display: flex; align-items: center; gap: 6px; }
.group-edit-form { display: flex; align-items: center; gap: 6px; flex: 1; }
.group-edit-form input[type="text"] { max-width: 260px; padding: 7px 10px; font-size: 12px; }
.sort-input { width: 66px !important; padding: 7px 8px !important; font-size: 11px !important; }
.group-add-form { display: flex; align-items: center; gap: 6px; padding-top: 9px; border-top: 1px dashed #eef2f8; }
.group-add-form input[type="text"] { max-width: 260px; padding: 7px 10px; font-size: 12px; }
.deploy-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.deploy-box { border: 1px solid #f1f5f9; border-radius: 11px; padding: 10px 12px; background: #fbfcfe; }
.deploy-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 10.5px; color: var(--muted); margin-bottom: 6px; }
.deploy-code { display: block; font-size: 9.5px; color: var(--text-2); word-break: break-all; background: #f3f7fd; border-radius: 6px; padding: 6px 8px; }
.deploy-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; font-size: 9.5px; color: var(--muted-2); }
.deploy-foot form { display: inline-flex; }
.checks-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin-bottom: 12px; }
.check-item { display: flex; align-items: flex-start; gap: 7px; padding: 8px 9px; border-radius: 8px; background: #fbfcfe; border: 1px solid #f1f5f9; }
.check-item svg { width: 14px; height: 14px; margin-top: 1px; }
.check-item.ok svg { color: #16a34a; }
.check-item.bad svg { color: #dc2626; }
.check-item div { display: flex; flex-direction: column; min-width: 0; }
.check-item strong { font-size: 10px; }
.check-item small { font-size: 9px; color: var(--muted-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.runtime-row { display: flex; flex-wrap: wrap; gap: 16px; font-size: 10px; color: var(--muted-2); border-top: 1px solid #f1f5f9; padding-top: 10px; }
.runtime-row strong { color: var(--text-2); font-weight: 600; }
.hidden-form { display: none; }

/* ---------- 登录 / 安装 ---------- */
.auth-page { min-height: 100vh; background: #f4f7fc; display: flex; align-items: center; justify-content: center; position: relative; overflow-x: hidden; padding: 28px 18px; }
.auth-bg { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.auth-blob { position: absolute; border-radius: 50%; filter: blur(10px); opacity: .55; }
.blob-a { width: 520px; height: 520px; background: radial-gradient(circle, #dbeafe, transparent 65%); top: -160px; left: -120px; }
.blob-b { width: 560px; height: 560px; background: radial-gradient(circle, #ede9fe, transparent 65%); bottom: -220px; right: -140px; }
.auth-shell { position: relative; width: 100%; max-width: 430px; z-index: 1; }
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; justify-content: center; }
.auth-brand > div:last-child { display: flex; flex-direction: column; }
.auth-brand strong { font-size: 14px; font-weight: 800; }
.auth-brand span { font-size: 9px; color: var(--muted-2); letter-spacing: .8px; text-transform: uppercase; }
.brand-mark { width: 38px; height: 38px; border-radius: 11px; background: linear-gradient(135deg, #4f8bff, #1d4ed8); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 17px; box-shadow: 0 8px 18px rgba(37, 99, 235, .25); }
.auth-card { background: #fff; border: 1px solid rgba(226, 232, 240, .9); border-radius: 20px; box-shadow: 0 24px 70px rgba(15, 23, 42, .09); padding: 30px 30px 24px; }
.auth-head { margin-bottom: 20px; }
.auth-head h1 { font-size: 22px; font-weight: 800; letter-spacing: -.4px; }
.auth-head p { font-size: 12px; color: var(--muted); margin-top: 4px; }
.auth-alert { display: flex; gap: 8px; align-items: flex-start; border-radius: 9px; padding: 9px 11px; font-size: 11.5px; margin-bottom: 13px; background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.auth-alert.success { background: #f0fdf4; color: #15803d; border-color: #bbf7d0; }
.auth-alert svg { width: 15px; height: 15px; margin-top: 1px; }
.auth-form { display: flex; flex-direction: column; gap: 13px; }
.auth-form .field { gap: 5px; }
.auth-form .field > span { font-size: 11.5px; }
.input-wrap { position: relative; }
.input-wrap > svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted-2); }
.input-wrap input { padding-left: 35px; padding-right: 38px; height: 42px; }
.input-action { position: absolute; right: 7px; top: 50%; transform: translateY(-50%); width: 28px; height: 28px; border: 0; background: transparent; color: var(--muted-2); display: flex; align-items: center; justify-content: center; border-radius: 6px; }
.input-action:hover { background: #f1f5f9; }
.input-action svg { width: 14px; height: 14px; }
.auth-foot { margin-top: 18px; padding-top: 14px; border-top: 1px solid #f1f5f9; display: flex; justify-content: center; font-size: 10.5px; color: var(--muted-2); }
.auth-foot span { display: flex; align-items: center; gap: 4px; }
.auth-foot svg { width: 12px; height: 12px; }
.auth-foot a { color: var(--primary); font-weight: 600; }
.auth-copyright { text-align: center; font-size: 10px; color: #a9b6c8; margin-top: 18px; }

.install-page { align-items: flex-start; padding: 36px 24px; }
.install-shell { position: relative; z-index: 1; width: 100%; max-width: 1120px; display: grid; grid-template-columns: minmax(0, 1fr) 520px; gap: 48px; align-items: start; }
.install-side { padding-top: 10px; }
.install-side .auth-brand { justify-content: flex-start; margin-bottom: 30px; }
.install-side h1 { font-size: 32px; line-height: 1.3; letter-spacing: -1px; font-weight: 800; margin-bottom: 12px; }
.install-lead { font-size: 13px; color: var(--muted); line-height: 1.8; max-width: 440px; }
.checks { list-style: none; padding: 0; margin: 26px 0 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; max-width: 500px; }
.checks li { display: flex; align-items: flex-start; gap: 7px; background: rgba(255, 255, 255, .7); border: 1px solid #e7eef8; border-radius: 9px; padding: 8px 9px; }
.checks svg { width: 14px; height: 14px; margin-top: 1px; }
.checks li.ok svg { color: #16a34a; }
.checks li.bad svg { color: #dc2626; }
.checks div { display: flex; flex-direction: column; min-width: 0; }
.checks strong { font-size: 10px; }
.checks small { font-size: 8.5px; color: var(--muted-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.install-note { font-size: 10px; color: var(--muted-2); margin-top: 14px; max-width: 420px; line-height: 1.6; }
.install-main { min-width: 0; }
.install-card { padding: 26px 26px 22px; }
.step-pill { display: inline-block; background: var(--primary-soft); color: var(--primary); font-size: 9px; font-weight: 700; padding: 3px 8px; border-radius: 999px; margin-bottom: 7px; }
.form-hint { font-size: 10px; color: var(--muted-2); text-align: center; }

/* ---------- 空 / 响应式 ---------- */
.drawer-mask { position: fixed; inset: 0; background: rgba(15, 23, 42, .35); z-index: 110; }
body.rail-open .rail { position: fixed; left: 0; top: 0; bottom: 0; box-shadow: 0 0 40px rgba(15, 23, 42, .18); }

@media (max-width: 1180px) {
    .workspace { grid-template-columns: 330px minmax(0, 1fr); }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .chat-actions .soft-button span { display: none; }
    .chat-actions .soft-button { padding: 7px; }
    .identity-switch { display: none !important; }
}

@media (max-width: 980px) {
    .rail { display: none; }
    body.rail-open .rail {
        display: flex;
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: 232px;
        align-items: flex-start;
        padding: 16px 12px;
        z-index: 120;
        box-shadow: 0 0 50px rgba(15, 23, 42, .2);
    }
    body.rail-open .rail-logo { margin-left: 4px; }
    body.rail-open .rail-nav { width: 100%; margin-top: 16px; }
    body.rail-open .rail-link { width: 100%; height: 42px; justify-content: flex-start; gap: 12px; padding: 0 12px; }
    body.rail-open .rail-link.active::before { left: -12px; top: 10px; bottom: 10px; }
    body.rail-open .rail-tip {
        display: block;
        position: static;
        opacity: 1;
        transform: none;
        background: transparent;
        color: inherit;
        box-shadow: none;
        padding: 0;
        font-size: 13px;
        font-weight: 600;
    }
    body.rail-open .rail-badge { position: static; margin-left: auto; border: 0; }
    body.rail-open .rail-bottom { width: 100%; flex-direction: row; justify-content: space-between; padding: 0 8px; }
    body.rail-open .rail-bottom .rail-link { width: auto; height: 36px; padding: 0 8px; }
    body.rail-open .rail-user { margin: 0; }
    .menu-btn { display: inline-flex; }
    .home-link { display: none; }
    .crumb-sep { display: none; }
    .topbar { padding: 0 15px; }
    .topbar-title { font-size: 15px; }
    .page-wrap { padding: 20px 18px 44px; }
    .dashboard-grid, .dashboard-grid.lower { grid-template-columns: 1fr; }
    .merchant-grid { grid-template-columns: 1fr; }
    .split-layout { grid-template-columns: 1fr; }
    .sticky-card { position: static; }
    .install-shell { grid-template-columns: 1fr; gap: 24px; max-width: 560px; }
    .install-side h1 { font-size: 25px; }
    .install-side .checks { grid-template-columns: 1fr 1fr; }
    .form-grid.three { grid-template-columns: 1fr 1fr; }
    .event-grid { grid-template-columns: 1fr; }
    .deploy-grid { grid-template-columns: 1fr; }
    .checks-grid { grid-template-columns: 1fr 1fr; }
    .workspace { grid-template-columns: 1fr; }
    .conv-panel { display: flex; }
    .chat-panel { display: none; }
    .workspace.chat-open .conv-panel { display: none; }
    .workspace.chat-open .chat-panel { display: flex; }
    .back-button { display: inline-flex; }
    .chat-actions .soft-button span { display: inline; }
    .chat-actions .soft-button { padding: 7px 10px; }
    .messages { padding: 18px 16px 12px; }
    .composer { padding: 8px 14px 12px; }
    .info-panel { width: 100%; border-left: 0; }
    .chat-head { padding: 9px 12px; }
    .chat-actions { gap: 4px; }
    .chat-actions #soundButton, .chat-actions #infoButton { display: none; }
    .lang-pill { display: none; }
    .page-heading { flex-direction: column; }
    .heading-actions { width: 100%; }
}

@media (max-width: 720px) {
    .topbar { height: 58px; }
    .user-meta { display: none; }
    .user-button > svg { display: none; }
    .flash-stack { left: 12px; right: 12px; top: 66px; max-width: none; }
    .stat-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
    .stat-card { padding: 13px; gap: 9px; }
    .stat-body strong { font-size: 21px; }
    .stat-body small { display: none; }
    .mini-stat-grid { grid-template-columns: 1fr 1fr; }
    .form-grid.two, .form-grid.three { grid-template-columns: 1fr; }
    .form-card { padding: 0 15px 18px; }
    .settings-card { padding: 0 15px 16px; }
    .checks-grid { grid-template-columns: 1fr; }
    .auth-card { padding: 24px 20px 20px; border-radius: 16px; }
    .install-page { padding: 20px 14px; }
    .install-side .checks { grid-template-columns: 1fr; }
    .checks { grid-template-columns: 1fr; }
    .day-pills { gap: 4px; }
    .day-pill span { padding: 5px 9px; font-size: 10.5px; }
    .page-heading h1 { font-size: 22px; }
    .toolbar { padding: 12px; }
    .toolbar-search { max-width: none; }
    .toolbar-select { flex: 1; min-width: 110px; }
    .group-edit-form input[type="text"] { max-width: none; }
    .group-add-form { flex-wrap: wrap; }
    .group-add-form input[type="text"] { max-width: none; flex: 1; }
    .save-bar { flex-direction: column; align-items: stretch; }
    .save-bar .btn { width: 100%; }
    .merchant-actions .btn { flex: 1; }
    .chat-tags .tag:nth-child(n+3) { display: none; }
    .msg-content { max-width: 78%; }
    .composer-tip { display: none; }
    .emoji-panel { left: 10px; width: min(294px, calc(100vw - 20px)); }
    .quick-panel { left: 10px; width: min(340px, calc(100vw - 20px)); }
    .conv-filters { padding-bottom: 9px; }
    .filter-grid { gap: 5px; }
    .conv-head { padding-top: 13px; }
    .conv-item { padding: 11px 13px; }
    .closed-banner { flex-direction: column; align-items: flex-start; gap: 6px; }
    .chat-head { flex-wrap: wrap; row-gap: 7px; align-items: center; padding: 8px 12px 9px; }
    .chat-identity { flex: 1; min-width: 0; }
    .chat-actions { order: 3; width: 100%; justify-content: flex-end; gap: 5px; }
    .chat-actions .soft-button { padding: 6px 9px; }
    .chat-actions .soft-button span { display: inline; }
    .chat-name-line h3 { font-size: 14px; }
    .chat-tags { flex-wrap: nowrap; overflow: hidden; }
}
