/* =========================================================
   多商户在线客服系统 - 全局样式
   ========================================================= */
:root {
    --brand: #4f46e5;
    --brand-2: #06b6d4;
    --brand-soft: #eef2ff;
    --ink: #0f172a;
    --text: #334155;
    --muted: #64748b;
    --line: #e2e8f0;
    --line-2: #eef2f7;
    --bg: #f4f6fb;
    --panel: #ffffff;
    --ok: #059669;
    --ok-soft: #ecfdf5;
    --warn: #d97706;
    --warn-soft: #fffbeb;
    --danger: #dc2626;
    --danger-soft: #fef2f2;
    --sidebar: #0f172a;
    --radius: 14px;
    --shadow: 0 10px 30px rgba(15, 23, 42, .06);
    --shadow-lg: 0 24px 60px rgba(15, 23, 42, .14);
    --font: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { opacity: .88; }
h1, h2, h3, h4 { margin: 0; color: var(--ink); font-weight: 700; line-height: 1.35; }
p { margin: 0; }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { width: 20px; height: 20px; flex: none; }
::selection { background: rgba(79, 70, 229, .18); }

/* 滚动条 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* ========================= 通用组件 ========================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    height: 38px;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: #fff;
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    transition: .18s ease;
    user-select: none;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn svg { width: 17px; height: 17px; }
.btn-primary {
    background: linear-gradient(135deg, var(--brand), #6366f1);
    color: #fff;
    box-shadow: 0 8px 18px rgba(79, 70, 229, .28);
}
.btn-ghost { background: #fff; border-color: var(--line); color: var(--text); }
.btn-ghost:hover { border-color: #cbd5e1; background: #fbfcfe; }
.btn-danger { background: var(--danger-soft); color: var(--danger); border-color: #fecaca; }
.btn-ok { background: var(--ok-soft); color: var(--ok); border-color: #a7f3d0; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 12px; border-radius: 8px; }
.btn-lg { height: 46px; font-size: 15px; border-radius: 12px; }
.btn-block { width: 100%; }
.btn:disabled, .btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; }
.btn-icon { width: 34px; height: 34px; padding: 0; border-radius: 9px; }

.field { margin-bottom: 15px; }
.field > label {
    display: block;
    font-size: 12.5px;
    font-weight: 650;
    color: var(--ink);
    margin-bottom: 6px;
}
.field input, .field select, .field textarea, .input {
    width: 100%;
    height: 42px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fbfcfe;
    outline: none;
    font-size: 13.5px;
    transition: .18s ease;
}
.field textarea, textarea.input { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus {
    border-color: var(--brand);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, .12);
}
.field .hint, .hint { font-size: 12px; color: var(--muted); margin-top: 5px; line-height: 1.6; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.checkbox {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    cursor: pointer;
    user-select: none;
}
.checkbox input { width: 16px; height: 16px; accent-color: var(--brand); }

.alert {
    border-radius: 11px;
    padding: 11px 14px;
    font-size: 13px;
    line-height: 1.65;
    margin-bottom: 16px;
    border: 1px solid transparent;
}
.alert-err { background: var(--danger-soft); color: #b91c1c; border-color: #fecaca; }
.alert-ok { background: var(--ok-soft); color: #047857; border-color: #a7f3d0; }
.alert-warn { background: var(--warn-soft); color: #92400e; border-color: #fde68a; }
.alert-info { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 650;
    line-height: 1.5;
    background: #f1f5f9;
    color: var(--muted);
    white-space: nowrap;
}
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-brand { background: var(--brand-soft); color: var(--brand); }
.badge-dot::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.card-pad { padding: 20px 22px; }
.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 17px 22px;
    border-bottom: 1px solid var(--line-2);
}
.card-head h3 { font-size: 15px; }
.card-head p { font-size: 12px; color: var(--muted); margin-top: 2px; }
.card-body { padding: 20px 22px; }
.card-foot { padding: 14px 22px; border-top: 1px solid var(--line-2); }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
.stack { display: grid; gap: 18px; }
.flex { display: flex; align-items: center; gap: 10px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.flex-wrap { flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.text-right { text-align: right; }
.text-danger { color: var(--danger); }
.text-ok { color: var(--ok); }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-2 { margin-bottom: 16px; }
.w-full { width: 100%; }

/* 空状态 */
.empty {
    padding: 46px 20px;
    text-align: center;
    color: var(--muted);
    font-size: 13px;
}
.empty .empty-icon {
    width: 54px;
    height: 54px;
    margin: 0 auto 12px;
    border-radius: 18px;
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
}
.empty .empty-icon svg { width: 26px; height: 26px; }

/* 表格 */
.table-wrap { width: 100%; overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.table th {
    text-align: left;
    font-size: 11.5px;
    font-weight: 650;
    letter-spacing: .02em;
    color: var(--muted);
    background: #f8fafc;
    padding: 11px 14px;
    border-bottom: 1px solid var(--line-2);
    white-space: nowrap;
}
table.table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--line-2);
    vertical-align: middle;
}
table.table tbody tr:hover td { background: #fbfcff; }
table.table tbody tr:last-child td { border-bottom: none; }
.table-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.table-empty { padding: 36px 16px; text-align: center; color: var(--muted); }

/* 分段筛选 */
.seg {
    display: inline-flex;
    background: #f1f5f9;
    border-radius: 10px;
    padding: 3px;
    gap: 2px;
}
.seg button {
    border: none;
    background: transparent;
    color: var(--muted);
    font-size: 12.5px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 8px;
}
.seg button.active { background: #fff; color: var(--ink); box-shadow: 0 1px 4px rgba(15, 23, 42, .1); }

/* 统计卡片 */
.stat {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}
.stat-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stat-label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.stat-icon {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: var(--brand-soft);
    color: var(--brand);
    display: flex;
    align-items: center;
    justify-content: center;
}
.stat-icon.green { background: var(--ok-soft); color: var(--ok); }
.stat-icon.orange { background: var(--warn-soft); color: var(--warn); }
.stat-icon.red { background: var(--danger-soft); color: var(--danger); }
.stat-icon.cyan { background: #ecfeff; color: #0891b2; }
.stat-value { font-size: 28px; font-weight: 750; color: var(--ink); margin-top: 10px; letter-spacing: -.02em; line-height: 1.2; }
.stat-sub { font-size: 12px; color: var(--muted); margin-top: 5px; }

/* 柱状图 */
.chart-bars {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    height: 170px;
    padding: 8px 2px 0;
}
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.chart-bar-wrap { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; }
.chart-bar {
    width: 60%;
    max-width: 34px;
    min-height: 3px;
    border-radius: 8px 8px 4px 4px;
    background: linear-gradient(180deg, #818cf8, var(--brand));
    transition: height .4s ease;
    position: relative;
}
.chart-bar.green { background: linear-gradient(180deg, #34d399, #059669); }
.chart-bar .chart-val {
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10.5px;
    color: var(--muted);
    white-space: nowrap;
}
.chart-label { font-size: 10.5px; color: var(--muted); white-space: nowrap; }
.chart-legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); }
.chart-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 5px; }

/* 会话列表/消息气泡（客服工作台 + 访客页共用） */
.msg-row { display: flex; gap: 9px; margin-bottom: 14px; align-items: flex-start; }
.msg-row .msg-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #e2e8f0;
    color: #475569;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11.5px;
    font-weight: 700;
    flex: none;
    margin-top: 2px;
}
.msg-main { max-width: min(78%, 560px); }
.msg-meta { font-size: 10.5px; color: #94a3b8; margin-bottom: 3px; display: flex; gap: 6px; align-items: center; }
.msg-bubble {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 4px 14px 14px 14px;
    padding: 9px 13px;
    font-size: 13.5px;
    line-height: 1.65;
    color: var(--text);
    word-break: break-word;
    white-space: pre-wrap;
    box-shadow: 0 3px 10px rgba(15, 23, 42, .03);
}
.msg-bubble img { display: block; border-radius: 8px; max-width: 240px; max-height: 240px; cursor: zoom-in; }
.msg-row.mine { flex-direction: row-reverse; }
.msg-row.mine .msg-main { display: flex; flex-direction: column; align-items: flex-end; }
.msg-row.mine .msg-meta { flex-direction: row-reverse; }
.msg-row.mine .msg-bubble {
    background: linear-gradient(135deg, var(--brand), #6366f1);
    color: #fff;
    border-color: transparent;
    border-radius: 14px 4px 14px 14px;
    box-shadow: 0 6px 16px rgba(79, 70, 229, .2);
}
.msg-row.mine .msg-avatar { background: var(--brand-soft); color: var(--brand); }
.msg-system { text-align: center; margin: 12px 0; }
.msg-system span {
    display: inline-block;
    font-size: 11px;
    color: #94a3b8;
    background: #f1f5f9;
    padding: 4px 10px;
    border-radius: 20px;
    max-width: 90%;
}
.msg-time { font-size: 10px; color: #94a3b8; margin-top: 4px; }

/* 头像 */
.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    color: #fff;
    font-weight: 700;
    flex: none;
}
.avatar-sm { width: 32px; height: 32px; font-size: 12.5px; }
.avatar-md { width: 40px; height: 40px; font-size: 14px; }
.avatar-lg { width: 52px; height: 52px; font-size: 18px; }

/* ========================= 登录页 ========================= */
.auth-page {
    min-height: 100vh;
    background: #f4f6fb;
}
.auth-wrap {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.08fr .92fr;
}
.auth-hero {
    position: relative;
    overflow: hidden;
    padding: 52px 58px;
    color: #fff;
    background:
        radial-gradient(700px 420px at 85% 5%, rgba(6, 182, 212, .35), transparent 65%),
        radial-gradient(650px 420px at 5% 90%, rgba(99, 102, 241, .5), transparent 65%),
        linear-gradient(135deg, #0f172a, #1e1b4b 55%, #0f172a);
    display: flex;
    flex-direction: column;
}
.auth-hero::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image: linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px);
    background-size: 46px 46px;
    mask-image: linear-gradient(to bottom, rgba(0,0,0,.5), transparent 80%);
    pointer-events: none;
}
.auth-brand { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 17px; position: relative; z-index: 1; }
.auth-hero h1 {
    position: relative;
    z-index: 1;
    color: #fff;
    font-size: clamp(30px, 3.4vw, 46px);
    line-height: 1.25;
    letter-spacing: -.02em;
    margin-top: 13vh;
}
.auth-sub { position: relative; z-index: 1; margin-top: 18px; color: rgba(255,255,255,.72); font-size: 14px; }
.auth-features {
    position: relative;
    z-index: 1;
    list-style: none;
    padding: 0;
    margin: 40px 0 0;
    display: grid;
    gap: 13px;
    max-width: 440px;
}
.auth-features li {
    display: flex;
    align-items: center;
    gap: 13px;
    color: rgba(255,255,255,.86);
    font-size: 13.5px;
    padding: 11px 14px;
    border: 1px solid rgba(255,255,255,.09);
    border-radius: 12px;
    background: rgba(255,255,255,.04);
    backdrop-filter: blur(4px);
}
.auth-features li span {
    font-size: 11px;
    font-weight: 700;
    color: #a5b4fc;
    background: rgba(99, 102, 241, .18);
    border-radius: 7px;
    padding: 2px 7px;
}
.auth-foot { position: relative; z-index: 1; margin-top: auto; padding-top: 40px; color: rgba(255,255,255,.42); font-size: 12px; }
.auth-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 28px;
    background:
        radial-gradient(600px 300px at 100% 0, rgba(6, 182, 212, .08), transparent 60%),
        radial-gradient(500px 300px at 0 100%, rgba(79, 70, 229, .08), transparent 60%),
        #f7f8fd;
}
.auth-card {
    width: 100%;
    max-width: 400px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    padding: 34px 34px 28px;
}
.auth-card h2 { font-size: 24px; letter-spacing: -.02em; }
.auth-tip { color: var(--muted); font-size: 12.5px; margin: 6px 0 24px; }
.auth-card .btn-block { margin-top: 4px; }
.auth-links {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-top: 20px;
    padding-top: 18px;
    border-top: 1px solid var(--line-2);
    font-size: 12px;
    color: var(--muted);
}
.captcha-row { display: flex; gap: 10px; }
.captcha-row input { flex: 1; }
.captcha-img {
    width: 130px;
    height: 42px;
    border-radius: 10px;
    border: 1px solid var(--line);
    cursor: pointer;
    background: #f8fafc;
    flex: none;
}

/* ========================= 后台框架 ========================= */
.shell { display: flex; min-height: 100vh; }
.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    width: 236px;
    flex: none;
    background:
        radial-gradient(420px 260px at 100% 0, rgba(6, 182, 212, .16), transparent 60%),
        linear-gradient(180deg, #111827, #0f172a 55%, #0b1220);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    padding: 18px 14px 14px;
    z-index: 30;
}
.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 6px 8px 20px;
    color: #fff;
}
.brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 13px;
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 15px;
    letter-spacing: -.03em;
    color: #fff;
    box-shadow: 0 8px 20px rgba(79, 70, 229, .35);
    flex: none;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.brand-text strong { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text small { font-size: 10.5px; color: #94a3b8; margin-top: 2px; }
.nav { display: flex; flex-direction: column; gap: 3px; margin-top: 4px; overflow-y: auto; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 11px;
    border-radius: 10px;
    color: #94a3b8;
    font-size: 13px;
    font-weight: 550;
    transition: .16s ease;
    position: relative;
}
.nav-item svg { width: 18px; height: 18px; opacity: .9; }
.nav-item:hover { background: rgba(255,255,255,.055); color: #e2e8f0; opacity: 1; }
.nav-item.active {
    background: linear-gradient(90deg, rgba(79,70,229,.28), rgba(79,70,229,.08));
    color: #fff;
}
.nav-item.active::before {
    content: "";
    position: absolute;
    left: -14px;
    top: 9px;
    bottom: 9px;
    width: 3px;
    border-radius: 0 4px 4px 0;
    background: var(--brand-2);
}
.nav-badge {
    margin-left: auto;
    font-style: normal;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--danger);
    color: #fff;
    font-size: 10.5px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.sidebar-foot {
    margin-top: auto;
    padding-top: 14px;
    border-top: 1px solid rgba(255,255,255,.07);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.user-mini { display: flex; align-items: center; gap: 9px; min-width: 0; }
.user-mini .avatar { background: rgba(255,255,255,.1); color: #e2e8f0; }
.user-mini-text { display: flex; flex-direction: column; line-height: 1.35; min-width: 0; }
.user-mini-text strong { color: #e2e8f0; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100px; }
.user-mini-text small { color: #64748b; font-size: 10.5px; }
.logout-form { margin: 0; }
.btn-logout {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    border: 1px solid rgba(255,255,255,.08);
    background: rgba(255,255,255,.04);
    color: #94a3b8;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: .16s;
    padding: 0;
}
.btn-logout svg { width: 16px; height: 16px; }
.btn-logout span { display: none; }
.btn-logout:hover { background: rgba(239,68,68,.14); color: #fca5a5; border-color: rgba(239,68,68,.25); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    height: 68px;
    flex: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0 26px;
    background: rgba(255,255,255,.86);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 20;
}
.topbar-title h1 { font-size: 18px; letter-spacing: -.01em; }
.topbar-title p { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.topbar-user { display: flex; align-items: center; gap: 9px; padding-left: 12px; border-left: 1px solid var(--line); }
.topbar-user-text { display: flex; flex-direction: column; line-height: 1.3; }
.topbar-user-text strong { font-size: 12px; color: var(--ink); }
.topbar-user-text small { font-size: 10.5px; color: var(--muted); }
.content { padding: 24px 26px 40px; flex: 1; min-width: 0; }
.content-agent { padding: 0; height: calc(100vh - 68px); overflow: hidden; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h2 { font-size: 20px; letter-spacing: -.02em; }
.page-head p { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.toolbar .input { height: 36px; width: 210px; }
.toolbar .field { margin: 0; }

.banner {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    border-radius: 12px;
    padding: 13px 16px;
    font-size: 13px;
    margin-bottom: 18px;
    border: 1px solid transparent;
}
.banner-warn { background: var(--warn-soft); border-color: #fde68a; color: #92400e; }
.banner-danger { background: var(--danger-soft); border-color: #fecaca; color: #b91c1c; }
.banner strong { font-weight: 700; }

.plan-card {
    background: linear-gradient(135deg, #1e1b4b, #312e81 50%, #0e7490);
    color: #fff;
    border-radius: 16px;
    padding: 22px;
    position: relative;
    overflow: hidden;
}
.plan-card::after {
    content: "";
    position: absolute;
    width: 220px;
    height: 220px;
    right: -60px;
    top: -100px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(6,182,212,.35), transparent 70%);
}
.plan-card h3 { color: #fff; font-size: 18px; }
.plan-card .plan-meta { color: rgba(255,255,255,.68); font-size: 12px; margin-top: 4px; }
.plan-price { font-size: 30px; font-weight: 800; margin-top: 14px; letter-spacing: -.02em; }
.plan-price small { font-size: 13px; font-weight: 500; color: rgba(255,255,255,.65); }
.plan-list { margin-top: 12px; display: grid; gap: 7px; font-size: 12.5px; color: rgba(255,255,255,.84); }
.plan-list li { list-style: none; display: flex; gap: 8px; align-items: center; }
.plan-list li::before { content: "✓"; color: #67e8f9; font-weight: 700; }
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.plan-box {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 18px;
    background: #fff;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: .18s;
}
.plan-box:hover { border-color: #c7d2fe; box-shadow: 0 12px 26px rgba(79,70,229,.08); transform: translateY(-2px); }
.plan-box.current { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79,70,229,.1); }
.plan-box h4 { font-size: 15px; }
.plan-box .price { font-size: 24px; font-weight: 750; color: var(--ink); }
.plan-box .price small { font-size: 12px; color: var(--muted); font-weight: 500; }
.plan-box .desc { font-size: 12px; color: var(--muted); min-height: 38px; }
.plan-box ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; font-size: 12.5px; color: var(--text); }
.plan-box li::before { content: "·"; color: var(--brand); font-weight: 800; margin-right: 6px; }

.widget-code {
    background: #0f172a;
    color: #e2e8f0;
    border-radius: 11px;
    padding: 14px 16px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    line-height: 1.7;
    word-break: break-all;
    position: relative;
}
.widget-code button { position: absolute; right: 8px; top: 8px; }

.detail-list { display: grid; gap: 12px; }
.detail-item { display: flex; justify-content: space-between; gap: 14px; font-size: 13px; padding-bottom: 10px; border-bottom: 1px dashed var(--line-2); }
.detail-item:last-child { border-bottom: none; padding-bottom: 0; }
.detail-item span:first-child { color: var(--muted); flex: none; }
.detail-item span:last-child { text-align: right; word-break: break-all; }

/* ========================= 客服工作台 ========================= */
.workbench {
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr) 272px;
    height: 100%;
    background: #fff;
}
.conv-panel { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; background: #fff; }
.conv-head { padding: 16px 16px 12px; border-bottom: 1px solid var(--line-2); flex: none; }
.conv-head-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.conv-head-top h2 { font-size: 15px; }
.conv-head-top .switch-wrap { display: flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--muted); }
.switch { position: relative; width: 36px; height: 20px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 20px; background: #cbd5e1; transition: .2s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; width: 14px; height: 14px; border-radius: 50%; background: #fff; top: 3px; left: 3px; transition: .2s; }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::after { left: 19px; }
.conv-search { position: relative; margin-top: 10px; }
.conv-search input { width: 100%; height: 34px; padding: 0 10px 0 32px; border: 1px solid var(--line); border-radius: 9px; background: #f8fafc; font-size: 12.5px; outline: none; }
.conv-search input:focus { border-color: var(--brand); background: #fff; box-shadow: 0 0 0 3px rgba(79,70,229,.1); }
.conv-search svg { position: absolute; left: 9px; top: 9px; width: 16px; height: 16px; color: #94a3b8; }
.conv-list { flex: 1; overflow-y: auto; padding: 6px; }
.conv-item {
    display: flex;
    gap: 10px;
    padding: 11px 10px;
    border-radius: 11px;
    cursor: pointer;
    transition: .15s;
    border: 1px solid transparent;
    position: relative;
}
.conv-item:hover { background: #f8fafc; }
.conv-item.active { background: var(--brand-soft); border-color: #e0e7ff; }
.conv-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #eef2ff;
    color: var(--brand);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    flex: none;
    position: relative;
}
.conv-avatar i {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #cbd5e1;
    border: 2px solid #fff;
}
.conv-avatar i.online { background: #10b981; }
.conv-body { flex: 1; min-width: 0; }
.conv-line1 { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.conv-name { font-size: 13px; font-weight: 650; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-time { font-size: 10.5px; color: #94a3b8; flex: none; }
.conv-line2 { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 2px; }
.conv-last { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-unread {
    min-width: 17px;
    height: 17px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
}
.conv-tags { display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap; }
.conv-tag { font-size: 9.5px; padding: 1px 6px; border-radius: 5px; background: #f1f5f9; color: var(--muted); }
.conv-tag.wait { background: var(--warn-soft); color: var(--warn); }
.conv-tag.rating { background: #fffbeb; color: #b45309; }

.chat-panel { display: flex; flex-direction: column; min-width: 0; background: #f8fafc; }
.chat-head {
    flex: none;
    background: #fff;
    border-bottom: 1px solid var(--line);
    padding: 12px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 62px;
}
.chat-head-left { display: flex; align-items: center; gap: 11px; min-width: 0; }
.chat-head-left h3 { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-head-left p { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.chat-head-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 20px 22px; scroll-behavior: smooth; }
.chat-msgs .msg-row:last-child { margin-bottom: 2px; }
.chat-start-tip { text-align: center; font-size: 11.5px; color: #94a3b8; margin: 4px 0 18px; }
.composer {
    flex: none;
    background: #fff;
    border-top: 1px solid var(--line);
    padding: 11px 16px 13px;
}
.composer-tools { display: flex; align-items: center; gap: 6px; margin-bottom: 7px; position: relative; }
.tool-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: .15s;
}
.tool-btn:hover { background: #f1f5f9; color: var(--ink); }
.tool-btn svg { width: 18px; height: 18px; }
.composer-box { display: flex; gap: 10px; align-items: flex-end; }
.composer textarea {
    flex: 1;
    min-height: 44px;
    max-height: 130px;
    padding: 11px 13px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: #fbfcfe;
    resize: none;
    outline: none;
    font-size: 13.5px;
    line-height: 1.55;
    transition: .16s;
}
.composer textarea:focus { border-color: var(--brand); background: #fff; box-shadow: 0 0 0 3px rgba(79,70,229,.1); }
.composer-tip { font-size: 10.5px; color: #94a3b8; margin-top: 6px; }

.info-panel { border-left: 1px solid var(--line); background: #fff; overflow-y: auto; min-width: 0; }
.info-block { padding: 18px 18px; border-bottom: 1px solid var(--line-2); }
.info-block h4 { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 12px; }
.info-visitor { text-align: center; padding-top: 22px; }
.info-visitor .avatar { margin: 0 auto 10px; }
.info-visitor h3 { font-size: 15px; }
.info-visitor p { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.info-row { display: flex; justify-content: space-between; gap: 12px; font-size: 12.5px; padding: 7px 0; border-bottom: 1px dashed var(--line-2); }
.info-row:last-child { border-bottom: none; }
.info-row span:first-child { color: var(--muted); flex: none; }
.info-row span:last-child { text-align: right; word-break: break-all; }
.quick-pop {
    position: absolute;
    bottom: 40px;
    left: 0;
    width: 320px;
    max-height: 320px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 6px;
    z-index: 30;
}
.quick-pop button {
    display: block;
    width: 100%;
    text-align: left;
    border: none;
    background: transparent;
    padding: 9px 10px;
    border-radius: 8px;
    font-size: 12.5px;
}
.quick-pop button:hover { background: #f1f5f9; }
.quick-pop button strong { display: block; font-size: 12px; color: var(--ink); margin-bottom: 2px; }
.quick-pop button span { color: var(--muted); font-size: 11.5px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.quick-pop .empty { padding: 20px 10px; }

.typing-dot { display: inline-flex; gap: 3px; align-items: center; }
.typing-dot i { width: 5px; height: 5px; border-radius: 50%; background: #94a3b8; animation: blink 1.2s infinite; }
.typing-dot i:nth-child(2) { animation-delay: .2s; }
.typing-dot i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* ========================= 访客聊天页 ========================= */
.visitor-page {
    min-height: 100vh;
    background:
        radial-gradient(800px 500px at 10% -10%, rgba(79,70,229,.16), transparent 65%),
        radial-gradient(800px 500px at 100% 0, rgba(6,182,212,.14), transparent 65%),
        #eef2f9;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 22px;
}
.chat-shell {
    width: 420px;
    max-width: 100%;
    height: 660px;
    max-height: calc(100vh - 44px);
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 30px 70px rgba(15,23,42,.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}
.chat-page-head {
    background: linear-gradient(135deg, var(--brand), #6366f1 60%, #0891b2);
    color: #fff;
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex: none;
    position: relative;
}
.chat-page-head::after {
    content: "";
    position: absolute;
    right: -30px;
    top: -60px;
    width: 160px;
    height: 160px;
    border-radius: 50%;
    background: rgba(255,255,255,.08);
}
.chat-page-head .avatar { background: rgba(255,255,255,.18); backdrop-filter: blur(6px); }
.chat-page-head h1 { color: #fff; font-size: 15px; }
.chat-status { display: flex; align-items: center; gap: 5px; font-size: 11px; color: rgba(255,255,255,.78); margin-top: 2px; }
.chat-status i { width: 6px; height: 6px; border-radius: 50%; background: #34d399; box-shadow: 0 0 0 3px rgba(52,211,153,.2); }
.chat-status.offline i { background: #fbbf24; box-shadow: 0 0 0 3px rgba(251,191,36,.2); }
.chat-head-btn {
    margin-left: auto;
    width: 32px;
    height: 32px;
    border-radius: 9px;
    border: 1px solid rgba(255,255,255,.22);
    background: rgba(255,255,255,.1);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    z-index: 1;
}
.chat-head-btn svg { width: 16px; height: 16px; }
.chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 18px 18px 8px;
    background:
        radial-gradient(600px 300px at 100% 100%, rgba(238,242,255,.8), transparent 60%),
        #f8fafc;
}
.chat-notice {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    background: #fff7ed;
    border: 1px solid #fed7aa;
    color: #9a3412;
    font-size: 11.5px;
    padding: 9px 11px;
    border-radius: 10px;
    margin-bottom: 14px;
    line-height: 1.6;
}
.chat-composer { flex: none; border-top: 1px solid var(--line); background: #fff; padding: 10px 12px 12px; }
.chat-composer-tools { display: flex; align-items: center; gap: 4px; margin-bottom: 6px; }
.chat-composer .composer-inline { display: flex; gap: 8px; align-items: flex-end; }
.chat-composer textarea {
    flex: 1;
    min-height: 42px;
    max-height: 110px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: #fbfcfe;
    padding: 10px 12px;
    resize: none;
    outline: none;
    font-size: 13px;
    line-height: 1.55;
}
.chat-composer textarea:focus { border-color: var(--brand); background: #fff; box-shadow: 0 0 0 3px rgba(79,70,229,.1); }
.chat-send {
    width: 44px;
    height: 42px;
    border-radius: 11px;
    border: none;
    background: linear-gradient(135deg, var(--brand), #6366f1);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 18px rgba(79,70,229,.28);
    padding: 0;
}
.chat-send:disabled { opacity: .5; }
.chat-send svg { width: 18px; height: 18px; }
.chat-foot {
    flex: none;
    text-align: center;
    font-size: 10px;
    color: #94a3b8;
    padding: 7px 10px 9px;
    background: #fff;
    border-top: 1px solid #f1f5f9;
}
.chat-foot a { color: #94a3b8; text-decoration: underline; }
.chat-rating {
    flex: none;
    background: #fff;
    border-top: 1px solid var(--line-2);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 12px;
    flex-wrap: wrap;
}
.stars { display: inline-flex; gap: 4px; }
.stars button {
    border: none;
    background: transparent;
    font-size: 20px;
    line-height: 1;
    color: #d1d5db;
    padding: 0;
    transition: .15s;
}
.stars button.on, .stars button:hover { color: #f59e0b; transform: scale(1.08); }

.chat-offline-card { padding: 26px 22px; display: flex; flex-direction: column; gap: 12px; }
.chat-offline-card h2 { font-size: 17px; }
.chat-offline-card p { font-size: 12.5px; color: var(--muted); line-height: 1.7; }
.ticket-form { display: grid; gap: 10px; margin-top: 4px; }
.ticket-form input, .ticket-form textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fbfcfe;
    padding: 9px 11px;
    font-size: 12.5px;
    outline: none;
}
.ticket-form textarea { min-height: 90px; resize: vertical; }
.ticket-form input:focus, .ticket-form textarea:focus { border-color: var(--brand); background: #fff; box-shadow: 0 0 0 3px rgba(79,70,229,.1); }
.ticket-form .btn { height: 40px; }

/* 访客页嵌入模式 */
.visitor-embed { padding: 0; background: #f8fafc; display: block; }
.visitor-embed .chat-shell { width: 100%; height: 100vh; max-height: none; border-radius: 0; box-shadow: none; }

/* 图片预览 */
.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, .86);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
    padding: 30px;
    cursor: zoom-out;
}
.lightbox img { max-width: 92vw; max-height: 88vh; border-radius: 10px; box-shadow: 0 20px 60px rgba(0,0,0,.5); }

/* 资料弹窗 */
.profile-box { display: grid; gap: 12px; }
.profile-box label { font-size: 12px; font-weight: 650; color: var(--ink); display: block; margin-bottom: 5px; }
.profile-box input {
    width: 100%;
    height: 40px;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0 11px;
    outline: none;
    background: #fbfcfe;
}
.profile-box input:focus { border-color: var(--brand); background: #fff; }

/* ========================= 弹窗 / 吐司 ========================= */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .48);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 22px;
    z-index: 200;
    animation: fadeIn .16s ease;
}
.modal {
    width: 100%;
    max-width: 520px;
    max-height: calc(100vh - 44px);
    background: #fff;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    animation: popIn .18s ease;
    overflow: hidden;
}
.modal.wide { max-width: 760px; }
.modal-head { padding: 17px 20px; border-bottom: 1px solid var(--line-2); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.modal-head h3 { font-size: 15px; }
.modal-close {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: none;
    background: #f1f5f9;
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}
.modal-close:hover { background: #e2e8f0; color: var(--ink); }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line-2); display: flex; justify-content: flex-end; gap: 10px; }
.modal .field:last-child { margin-bottom: 0; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }

.toast-wrap { position: fixed; top: 18px; right: 18px; z-index: 500; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
    min-width: 220px;
    max-width: 360px;
    background: #111827;
    color: #fff;
    border-radius: 11px;
    padding: 11px 14px;
    font-size: 12.5px;
    box-shadow: 0 14px 34px rgba(2, 6, 23, .28);
    display: flex;
    align-items: center;
    gap: 9px;
    animation: toastIn .2s ease;
    pointer-events: auto;
    line-height: 1.5;
}
.toast.ok { background: #065f46; }
.toast.err { background: #991b1b; }
.toast::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #a7f3d0; flex: none; }
.toast.err::before { background: #fecaca; }
@keyframes toastIn { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }

/* ========================= 错误页 ========================= */
.error-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); padding: 30px; }
.error-card { text-align: center; background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 46px 50px; box-shadow: var(--shadow); max-width: 460px; }
.error-code { font-size: 64px; font-weight: 800; letter-spacing: -.04em; background: linear-gradient(135deg, var(--brand), var(--brand-2)); -webkit-background-clip: text; background-clip: text; color: transparent; line-height: 1; }
.error-card h1 { font-size: 20px; margin-top: 12px; }
.error-card p { color: var(--muted); font-size: 13px; margin: 8px 0 22px; }

/* ========================= 响应式 ========================= */
@media (max-width: 1240px) {
    .workbench { grid-template-columns: 280px minmax(0, 1fr); }
    .info-panel { display: none; }
}
@media (max-width: 1024px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .auth-hero { padding: 40px 38px; }
    .auth-hero h1 { margin-top: 8vh; }
}
@media (max-width: 900px) {
    .shell { display: block; padding-bottom: 62px; }
    .sidebar {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        top: auto;
        height: 60px;
        width: 100%;
        flex-direction: row;
        align-items: center;
        padding: 6px 8px;
        background: rgba(15, 23, 42, .98);
        backdrop-filter: blur(10px);
        border-top: 1px solid rgba(255,255,255,.08);
    }
    .brand, .sidebar-foot, .user-mini { display: none; }
    .nav { flex-direction: row; margin: 0; width: 100%; overflow-x: auto; gap: 4px; justify-content: flex-start; }
    .nav-item { flex-direction: column; gap: 2px; padding: 6px 10px; font-size: 10px; min-width: 58px; text-align: center; border-radius: 9px; }
    .nav-item svg { width: 18px; height: 18px; }
    .nav-item.active::before { display: none; }
    .nav-badge { position: absolute; top: 2px; right: 6px; margin: 0; }
    .topbar { height: 60px; padding: 0 14px; }
    .topbar-title h1 { font-size: 16px; }
    .topbar-title p { display: none; }
    .topbar-user-text { display: none; }
    .topbar-actions .hide-mobile { display: none; }
    .topbar-logout { margin: 0; }
    .topbar-logout .btn { height: 30px; padding: 0 10px; }
    .content { padding: 16px 14px 28px; }
    .content-agent { height: calc(100vh - 60px - 60px); padding: 0; }
    .workbench { grid-template-columns: 1fr; position: relative; height: 100%; }
    .conv-panel {
        position: absolute;
        inset: 0 auto 0 0;
        width: min(86vw, 320px);
        z-index: 25;
        transform: translateX(-102%);
        transition: transform .22s ease;
        box-shadow: 12px 0 30px rgba(15,23,42,.16);
    }
    .workbench.list-open .conv-panel { transform: none; }
    .chat-head { padding: 10px 12px; min-height: 56px; }
    .chat-head-actions .btn span { display: none; }
    .chat-msgs { padding: 14px; }
    .composer { padding: 8px 10px 10px; }
    .mobile-only { display: inline-flex !important; }
    .auth-wrap { grid-template-columns: 1fr; }
    .auth-hero { display: none; }
    .auth-panel { min-height: 100vh; padding: 26px 18px; }
    .auth-card { padding: 28px 22px 24px; }
}
@media (max-width: 700px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .field-row { grid-template-columns: 1fr; }
    .page-head { flex-direction: column; align-items: stretch; }
    .toolbar .input { width: 100%; }
    .stat-value { font-size: 24px; }
    .table-wrap { font-size: 12.5px; }
    .modal-foot { flex-direction: column-reverse; }
    .modal-foot .btn { width: 100%; }
    .chat-shell { height: 100vh; max-height: none; border-radius: 0; }
    .visitor-page { padding: 0; background: #fff; }
}
.mobile-only { display: none; }
