/* ai_bot 后台样式 v3：全面视觉升级
   设计基调：保留浅色护眼底色，升级为「现代渐变品牌 + 细腻层次 + 微量动效」
   - 品牌色从单色 indigo 升级为多色渐变（indigo → violet → fuchsia）
   - 侧边栏带玻璃质感，激活项用渐变胶囊 + 左侧光柱
   - 卡片加顶部渐变高光 + 悬停抬升，统计块按语义分配强调色
   - 阴影改分层柔化，圆角、间距微调，滚动条 / 空态 / 表格一并打磨
   所有 class / 元素选择器保持与 v2 兼容，不破坏已有功能 */

:root {
    /* 中性色（微调让背景更有呼吸感） */
    --bg: #eef0f6;
    --bg-grad: radial-gradient(1200px 600px at 85% -10%, rgba(124, 92, 255, .10), transparent 60%),
               radial-gradient(900px 500px at -10% 20%, rgba(99, 102, 241, .08), transparent 55%);
    --panel: #ffffff;
    --panel-2: #f8f9fd;
    --panel-3: #f2f4fb;
    --line: #e9ecf3;
    --line-strong: #d8deeb;
    --text: #141a2c;
    --text-2: #46536b;
    --muted: #8a94a8;

    /* 品牌色：基底保持与旧版一致的 indigo（#4f46e5），新增渐变辅色 */
    --brand: #4f46e5;
    --brand-2: #7c5cff;
    --brand-3: #b14ae8;
    --brand-grad: linear-gradient(135deg, #4f46e5 0%, #7c5cff 52%, #b14ae8 100%);
    --brand-grad-soft: linear-gradient(135deg, #eef0ff 0%, #f3ecff 60%, #fbeaff 100%);
    --brand-hover: #4338ca;
    --brand-soft: #eef0fe;
    --brand-ring: rgba(79, 70, 229, .16);
    --brand-glow: 0 8px 24px rgba(94, 84, 245, .28);

    /* 状态色 */
    --ok: #12a06a;
    --ok-soft: #e6f7ef;
    --bad: #e04a3d;
    --bad-soft: #fdecea;
    --warn: #c9821a;
    --warn-soft: #fdf3e2;

    /* 尺寸 */
    --sidebar-w: 236px;
    --radius: 16px;
    --radius-lg: 20px;
    --radius-sm: 10px;
    --shadow-sm: 0 1px 2px rgba(20, 26, 44, .04), 0 1px 3px rgba(20, 26, 44, .05);
    --shadow-md: 0 8px 24px rgba(20, 26, 44, .08), 0 2px 6px rgba(20, 26, 44, .05);
    --shadow-pop: 0 16px 44px rgba(20, 26, 44, .14), 0 4px 12px rgba(20, 26, 44, .08);
    --ease: cubic-bezier(.22, .61, .36, 1);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    font: 14px/1.6 -apple-system, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
    background-color: var(--bg);
    background-image: var(--bg-grad);
    background-attachment: fixed;
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-hover); }

/* 全站滚动条：更细腻 */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #cfd5e2; border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: #b6bdd0; background-clip: padding-box; border: 2px solid transparent; }
::-webkit-scrollbar-track { background: transparent; }

/* ================= 整体布局：左侧边栏 + 右侧内容 ================= */
.layout { display: flex; min-height: 100vh; }

/* ---------------- 侧边栏 ---------------- */
.sidebar {
    width: var(--sidebar-w);
    flex: 0 0 var(--sidebar-w);
    background: var(--panel);
    border-right: 1px solid var(--line);
    background-image: linear-gradient(180deg, #ffffff 0%, #fbfbfe 100%);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 20;
}

.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 22px 20px 20px;
    border-bottom: 1px solid var(--line);
    position: relative;
}
.brand .logo {
    width: 38px; height: 38px;
    flex: 0 0 38px;
    filter: drop-shadow(0 5px 12px rgba(105, 84, 238, .34));
}
.brand .logo svg, .brand .logo img { display: block; width: 100%; height: 100%; }
.brand .txt { line-height: 1.25; }
.brand .txt b { display: block; font-size: 15px; font-weight: 700; letter-spacing: .2px; background: linear-gradient(90deg, #312e81, #6d28d9); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.brand .txt span { display: block; font-size: 11px; color: var(--muted); margin-top: 1px; }

.nav { padding: 16px 12px; flex: 1; overflow-y: auto; }
.nav .group-label {
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .07em;
    padding: 12px 12px 7px;
    font-weight: 700;
}
.nav a {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-2);
    font-weight: 500;
    margin-bottom: 3px;
    position: relative;
    transition: background .18s var(--ease), color .18s var(--ease), transform .18s var(--ease);
}
.nav a svg { width: 18px; height: 18px; flex: 0 0 18px; opacity: .85; transition: opacity .18s; }
.nav a:hover { background: var(--panel-2); color: var(--text); transform: translateX(2px); text-decoration: none; }
.nav a:hover svg { opacity: 1; }
/* 激活项：渐变胶囊 + 左侧品牌色光柱 */
.nav a.active {
    background: var(--brand-grad-soft);
    color: #4f46e5;
    font-weight: 650;
    box-shadow: inset 0 0 0 1px rgba(124, 92, 255, .14);
    transform: none;
}
.nav a.active svg { opacity: 1; color: var(--brand); }
.nav a.active::before {
    content: "";
    position: absolute;
    left: -12px; top: 8px; bottom: 8px; width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--brand-grad);
    box-shadow: 0 0 8px rgba(124, 92, 255, .6);
}

.sidebar-foot {
    padding: 13px 16px;
    border-top: 1px solid var(--line);
    font-size: 11px;
    color: var(--muted);
    line-height: 1.6;
    background: linear-gradient(180deg, transparent, rgba(79,70,229,.03));
}
.sidebar-foot a { color: var(--muted); transition: color .15s; }
.sidebar-foot a:hover { color: var(--brand); }

/* ---------------- 主区 ---------------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.page-head {
    padding: 26px 34px 20px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, .72);
    backdrop-filter: saturate(1.4) blur(10px);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 1px 0 rgba(20, 26, 44, .02), 0 6px 20px -12px rgba(20, 26, 44, .12);
}
.page-head h1 {
    margin: 0; font-size: 21px; font-weight: 750; letter-spacing: .2px;
    background: linear-gradient(90deg, #1e1b4b, #4f46e5);
    -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.page-head .sub { margin: 5px 0 0; color: var(--text-2); font-size: 13px; max-width: 720px; opacity: .9; }
.page-head .head-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.content { padding: 26px 34px 70px; width: 100%; }
/* 默认铺满整个内容区；个别页面若要收窄阅读宽度，
   在模板里 {% block content_class %}narrow{% endblock %} */
.content.narrow, .flash-wrap.narrow { max-width: 1280px; }

/* 内容区进入时轻微上浮淡入 */
.content > * { animation: riseIn .4s var(--ease) backwards; }
@keyframes riseIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

/* ================= 栅格 ================= */
.grid { display: grid; gap: 20px; }
.grid.two { grid-template-columns: minmax(320px, 384px) 1fr; align-items: start; }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(156px, 1fr)); }
.grid.half { grid-template-columns: 1fr 1fr; align-items: start; }
@media (max-width: 1080px) { .grid.two { grid-template-columns: 1fr; } }
@media (max-width: 900px) { .grid.half { grid-template-columns: 1fr; } }

/* ================= 卡片 ================= */
.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
    overflow: hidden;
    position: relative;
    transition: box-shadow .22s var(--ease), transform .22s var(--ease), border-color .22s;
}
/* 顶部一条品牌渐变高光线，让卡片更有立体层次 */
.card::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, #4f46e5, #7c5cff, #b14ae8, transparent 92%);
    opacity: .0;
    transition: opacity .22s;
}
.card:hover::before { opacity: .85; }
/* 卡片头在视觉上更透气：右侧留操作位，标题附一道短渐变标 */
.card > .card-head {
    padding: 17px 22px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    background: linear-gradient(180deg, #ffffff, #fdfdff);
}
.card > .card-head h2 { margin: 0; font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.card > .card-head h2::before {
    content: "";
    width: 4px; height: 15px;
    border-radius: 3px;
    background: var(--brand-grad);
    box-shadow: 0 0 6px rgba(124, 92, 255, .45);
}
.card > .card-head .hint { margin: 3px 0 0 12px; color: var(--muted); font-size: 12px; }
.card > .card-body { padding: 20px 22px; }
.card > .card-body.flush { padding: 0; }
.card .hint { color: var(--muted); font-size: 12px; }

/* 兼容旧 macro（card_open 直接输出 h2 + p.hint） */
.card > h2 { margin: 0; padding: 17px 22px 0; font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.card > h2::before { content: ""; width: 4px; height: 15px; border-radius: 3px; background: var(--brand-grad); box-shadow: 0 0 6px rgba(124,92,255,.45); }
.card > h2 + .hint { padding: 3px 22px 0; margin: 0; }
.card > h2 small { font-weight: 400; color: var(--muted); margin-left: 8px; font-size: 12px; }

/* ================= 统计块 ================= */
.stat {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 17px 19px;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
    transition: box-shadow .22s var(--ease), transform .22s var(--ease), border-color .22s;
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: color-mix(in srgb, var(--accent, var(--brand)) 30%, var(--line)); }
.stat .label { color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 6px; font-weight: 550; letter-spacing: .3px; opacity: .92; }
.stat .value {
    font-size: 30px; font-weight: 780; line-height: 1.22; margin-top: 5px; letter-spacing: -.5px;
    background: var(--accent-grad, var(--brand-grad));
    -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.stat .hint { color: var(--muted); font-size: 12px; margin-top: 2px; }
.stat .bar {
    position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
    background: var(--accent-grad, var(--brand-grad));
    opacity: .95;
    border-radius: 0 4px 4px 0;
}
/* 统计块按语义分配强调色 —— 只在父级 grid.stats 内生效 */
.grid.stats .stat:nth-child(1) { --accent: #4f46e5; --accent-grad: linear-gradient(135deg, #4f46e5, #7c5cff); }
.grid.stats .stat:nth-child(2) { --accent: #7c3aed; --accent-grad: linear-gradient(135deg, #7c3aed, #b14ae8); }
.grid.stats .stat:nth-child(3) { --accent: #d946ef; --accent-grad: linear-gradient(135deg, #b14ae8, #d946ef); }
.grid.stats .stat:nth-child(4) { --accent: #f59e0b; --accent-grad: linear-gradient(135deg, #f59e0b, #f97316); }
.grid.stats .stat:nth-child(5) { --accent: #0ea5e9; --accent-grad: linear-gradient(135deg, #0ea5e9, #22d3ee); }

/* ================= 表单 ================= */
.field { display: block; margin-bottom: 15px; }
.field > span { display: block; font-size: 12.5px; color: var(--text-2); margin-bottom: 6px; font-weight: 600; }
.field .req { color: var(--bad); }
input, select, textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    font: inherit;
    background: #fff;
    color: var(--text);
    transition: border-color .18s var(--ease), box-shadow .18s var(--ease), background .18s;
}
input::placeholder, textarea::placeholder { color: #b6bdcb; }
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 4px var(--brand-ring), 0 2px 8px -2px var(--brand-ring);
    background: #fff;
}
textarea { resize: vertical; line-height: 1.55; }
/* 表格里的多选框：绕开上面 input 的「撑满 + 内边距」规则
   （写在 .switch input 之前，开关自己的 width:0 仍然优先） */
input[type="checkbox"] {
    width: auto;
    height: auto;
    padding: 0;
    margin: 0;
    accent-color: var(--brand);
    cursor: pointer;
    vertical-align: middle;
}
select { cursor: pointer; background-image: linear-gradient(45deg, transparent 50%, #8a94a8 50%), linear-gradient(135deg, #8a94a8 50%, transparent 50%);
    background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    appearance: none; -webkit-appearance: none; padding-right: 32px; }
.field small { display: block; color: var(--muted); font-size: 11.5px; margin-top: 5px; line-height: 1.55; }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .field-row { grid-template-columns: 1fr; } }

.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 18px; }

/* 表单分区标题 */
.form-section {
    font-size: 11px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .06em;
    margin: 20px 0 12px;
    padding-bottom: 7px;
    border-bottom: 1px dashed var(--line);
}
.form-section:first-child { margin-top: 0; }

/* 插件配置：插件中心的默认配置表单 + 机器人页里的插件区块 */
.plugin-config { max-width: 100%; }
.plugin-config .field-row { align-items: start; }
.form-foot { display: flex; gap: 8px; align-items: center; margin-top: 4px; }

/* 插件中心的账号分配：一屏两列列出所有机器人，机器人多了再纵向滚动 */
.acct-hint { margin: -4px 0 12px; }
.acct-warn { color: var(--bad); font-weight: 500; }
.acct-list { display: grid; grid-template-columns: 1fr 1fr; gap: 9px 24px; }
.acct-row {
    display: grid;
    grid-template-columns: 88px minmax(0, 1fr);
    align-items: center;
    gap: 9px;
    margin: 0;
}
.acct-row .acct-name {
    font-size: 12.5px;
    color: var(--text-2);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.acct-row select, .acct-row input { padding: 7px 10px; font-size: 12.5px; }
/* 账号列表与保存按钮之间留一口气，别贴在一起 */
.plugin-config .acct-list + .form-foot,
.plugin-config .acct-list ~ .form-foot { margin-top: 18px; }

/* ================= 按钮 ================= */
button, .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 15px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--text-2);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all .16s var(--ease);
    box-shadow: 0 1px 2px rgba(20, 26, 44, .04);
}
button:hover, .btn:hover {
    border-color: var(--brand);
    color: var(--brand);
    text-decoration: none;
    background: #fff;
    box-shadow: 0 3px 8px -2px var(--brand-ring);
    transform: translateY(-1px);
}
button:active, .btn:active { transform: translateY(0); }
button:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }
button.primary, .btn.primary {
    background: var(--brand-grad);
    border-color: transparent;
    color: #fff;
    background-size: 160% 100%;
    background-position: 0% 0;
    box-shadow: 0 3px 12px -2px rgba(94, 84, 245, .5);
}
button.primary:hover, .btn.primary:hover {
    background-position: 100% 0;
    color: #fff;
    border-color: transparent;
    box-shadow: 0 6px 18px -2px rgba(94, 84, 245, .55);
}
button.primary:active, .btn.primary:active { box-shadow: 0 2px 8px -2px rgba(94,84,245,.5); }
button.danger:hover, .btn.danger:hover { border-color: var(--bad); color: var(--bad); background: var(--bad-soft); box-shadow: 0 3px 8px -2px rgba(224, 74, 61, .3); transform: translateY(-1px); }
button.ghost, .btn.ghost { background: transparent; border-color: transparent; color: var(--muted); box-shadow: none; }
button.ghost:hover, .btn.ghost:hover { background: var(--panel-2); color: var(--text); border-color: transparent; transform: none; box-shadow: none; }
button.sm, .btn.sm { padding: 5px 10px; font-size: 12.5px; }
button.link { border: none; background: none; color: var(--brand); padding: 0; box-shadow: none; }
button.link:hover { transform: none; box-shadow: none; }

/* ================= 表格 ================= */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 12px 18px; border-bottom: 1px solid var(--line); vertical-align: middle; }
thead th {
    color: var(--text-2);
    font-weight: 700;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: .05em;
    background: linear-gradient(180deg, #f5f6fc, #f8f9fd);
    border-bottom: 1px solid var(--line-strong);
    white-space: nowrap;
    position: sticky;
    top: 0;
}
tbody tr { transition: background .13s; }
tbody tr:hover { background: var(--panel-3); }
tbody tr:last-child td { border-bottom: none; }
/* 批量删除：整行可点切换复选框，选中行高亮；操作列不显示手型 */
tbody tr.bulk-row { cursor: pointer; }
tbody tr.bulk-row td:last-child { cursor: default; }
tbody tr.bulk-row.row-selected { background: var(--brand-soft); }
/* 列表筛选条：按 col 思路分配 —— 一个下拉占 2 格，搜索框占 4 格，计数自适应 */
.filter-bar {
    display: grid; grid-template-columns: 2fr 2fr 2fr 4fr auto;
    gap: 8px; align-items: center;
    padding: 10px 22px; border-bottom: 1px solid var(--line);
    background: var(--panel-2);
}
.filter-bar select, .filter-bar input[type="search"] {
    height: 32px; padding: 0 10px; border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm); background: var(--panel);
    color: var(--text); font-size: 13px; outline: none;
    width: 100%; min-width: 0; text-overflow: ellipsis;
}
.filter-bar select:focus, .filter-bar input[type="search"]:focus {
    border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring);
}
.filter-bar .hint { font-size: 12px; white-space: nowrap; }
td:first-child, th:first-child { padding-left: 22px; }
td:last-child, th:last-child { padding-right: 22px; }
td.mono, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
td.nowrap, .nowrap { white-space: nowrap; }
td .row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
/* 操作列：按钮保持一行，宁可表格横向滚动，也不要把按钮挤成竖排 */
td.nowrap .row-actions { flex-wrap: nowrap; }
td .row-actions form { display: inline-flex; }
.cell-title { font-weight: 600; color: var(--text); }
td a.cell-title:hover { color: var(--brand); }
.cell-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
/* 固定列宽表格：列宽由表头决定，长文本单元格才能截断而不是把表格撑宽 */
table.table-fixed { table-layout: fixed; }
/* 单行显示 + 超出省略，完整内容放 title 里悬停可见 */
.cell-ellipsis {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

/* 表格内联快捷下拉（机器人页：默认模型 / 人设 就地切换） */
.quick-cell { display: flex; align-items: center; gap: 8px; }
.quick-select {
    width: auto;
    min-width: 150px;
    max-width: 240px;
    padding: 6px 30px 6px 10px;
    font-size: 12.5px;
    font-weight: 500;
    border-radius: 9px;
    background: #fff;
    text-overflow: ellipsis;
    border-color: var(--line-strong);
}
.quick-select:disabled { opacity: .6; cursor: progress; }
.saved-tip {
    font-size: 11.5px;
    color: var(--muted);
    white-space: nowrap;
    min-width: 40px;
}
.saved-tip.ok { color: var(--ok); font-weight: 600; }
.saved-tip.bad { color: var(--bad); font-weight: 600; }

/* ================= 徽标 / 状态点 ================= */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    background: #eef1f6;
    color: var(--text-2);
    white-space: nowrap;
    border: 1px solid transparent;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 0 currentColor; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.info { background: var(--brand-soft); color: var(--brand); }
.badge.ok .dot { animation: pulse 2s infinite; }
@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(18, 160, 106, .35); opacity: 1; }
    50% { box-shadow: 0 0 0 5px rgba(18, 160, 106, 0); opacity: .8; }
}

/* ================= Flash 提示 ================= */
.flash-wrap { padding: 16px 34px 0; width: 100%; }
.flash {
    padding: 11px 15px;
    border-radius: var(--radius-sm);
    margin-bottom: 14px;
    border: 1px solid;
    font-size: 13px;
    display: flex;
    align-items: flex-start;
    gap: 9px;
    box-shadow: var(--shadow-sm);
}
.flash::before { font-weight: 800; }
.flash.ok { background: var(--ok-soft); border-color: #bfe8d3; color: #0b6b45; }
.flash.ok::before { content: "✓"; }
.flash.bad { background: var(--bad-soft); border-color: #f5c6c1; color: #a8322a; }
.flash.bad::before { content: "!"; }

.empty { color: var(--muted); padding: 34px 16px; text-align: center; font-size: 13px; position: relative; }
.empty::before {
    content: "◌";
    display: block;
    font-size: 26px;
    margin-bottom: 6px;
    color: #c3c9d8;
    opacity: .7;
}
.muted { color: var(--muted); }

/* ================= 开关（Switch） ================= */
.switch-row {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    column-gap: 12px;
    margin-bottom: 14px;
}
.switch-row > span { font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.switch-row > small { grid-column: 1 / -1; color: var(--muted); font-size: 11.5px; margin-top: 5px; line-height: 1.5; }
/* 机器人弹窗里的插件开关组：只留名称 + 开关，和下个字段留出正常间距 */
.plugin-list { margin-bottom: 10px; }
.switch { position: relative; display: inline-block; width: 42px; height: 23px; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch .slider {
    position: absolute;
    inset: 0;
    background: var(--line-strong);
    border-radius: 999px;
    transition: background .2s, box-shadow .2s;
    cursor: pointer;
}
.switch .slider::before {
    content: "";
    position: absolute;
    width: 17px; height: 17px;
    left: 3px; top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform .2s var(--ease);
    box-shadow: 0 1px 3px rgba(20, 26, 44, .3);
}
.switch input:checked + .slider { background: var(--brand-grad); box-shadow: 0 2px 6px -1px rgba(124, 92, 255, .5); }
.switch input:checked + .slider::before { transform: translateX(19px); }
.switch input:focus-visible + .slider { box-shadow: 0 0 0 3px var(--brand-ring); }

/* ================= Modal 弹窗 ================= */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(18, 24, 44, .48);
    backdrop-filter: blur(6px);
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: 40px 16px;
    overflow-y: auto;
    z-index: 100;
}
.modal-backdrop.open { display: flex; }
.modal {
    background: var(--panel);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 560px;
    box-shadow: var(--shadow-pop);
    border: 1px solid var(--line);
    animation: modalIn .22s var(--ease);
}
@keyframes modalIn {
    from { opacity: 0; transform: translateY(14px) scale(.97); }
    to { opacity: 1; transform: none; }
}
.modal::before {
    content: "";
    position: absolute; top: 0; left: 0; right: 0; height: 3px;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    background: var(--brand-grad);
}
.modal-head {
    padding: 18px 22px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.modal-head h2 { margin: 0; font-size: 16px; font-weight: 700; }
.modal-head .hint { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.modal-close {
    background: none;
    border: none;
    padding: 4px 6px;
    font-size: 20px;
    line-height: 1;
    color: var(--muted);
    cursor: pointer;
    border-radius: 8px;
    transition: background .15s, color .15s;
}
.modal-close:hover { background: var(--panel-3); color: var(--text); }
.modal-body { padding: 20px 22px; max-height: 68vh; overflow-y: auto; }

/* 宽版弹窗：字段拆两栏，长表单一次显示完，不用来回滚 */
.modal.modal-lg { max-width: 940px; }
/* 中号弹窗：插件配置（凭证 + 两列账号列表） */
.modal.modal-mid { max-width: 820px; }
.modal-body.cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    /* 两列中间共 56px 空隙：28px 栅格间距 + 右栏 28px 左内边距，
       虚线正好落在正中间。 */
    column-gap: 28px;
    align-items: stretch;
    max-height: 76vh;
    padding-bottom: 6px;
}
.modal-body.cols > .mcol { min-width: 0; }
.modal-body.cols > .mcol + .mcol {
    padding-left: 28px;
    border-left: 1px dashed var(--line);
}
.modal-body.cols .mcol > .form-section:first-child { margin-top: 0; }

/* 两栏里把字段压紧一点，否则光间距就能把表单顶出屏幕 */
.modal-body.cols .field { margin-bottom: 11px; }
.modal-body.cols .field > span { margin-bottom: 4px; }
.modal-body.cols .field small { margin-top: 3px; }
/* 两栏里给分区标题加一道品牌色短竖条，读起来更有层次 */
.modal-body.cols .form-section {
    display: flex;
    align-items: center;
    gap: 7px;
    margin: 17px 0 11px;
}
.modal-body.cols .form-section::before {
    content: "";
    width: 3px;
    height: 12px;
    border-radius: 2px;
    background: var(--brand-grad);
    opacity: .6;
    flex: 0 0 3px;
}
.modal-body.cols .switch-row { margin-bottom: 5px; }
.modal-body.cols .switch-row > small { margin-top: 3px; }

/* 跨两栏的折叠说明（飞书配置步骤等） */
.modal-help {
    grid-column: 1 / -1;
    margin-top: 8px;
    padding: 12px 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--panel-2);
    font-size: 12.5px;
    color: var(--muted);
    line-height: 1.7;
    box-shadow: inset 0 1px 3px rgba(20,26,44,.03);
}
.modal-help summary {
    cursor: pointer;
    color: var(--text-2);
    font-weight: 600;
    list-style: none;
}
.modal-help summary::-webkit-details-marker { display: none; }
.modal-help summary::before {
    content: "▸";
    display: inline-block;
    margin-right: 6px;
    color: var(--brand);
    transition: transform .15s;
}
.modal-help[open] summary::before { transform: rotate(90deg); }
.modal-help ol { margin: 10px 0 0; padding-left: 20px; }
.modal-help li { margin-bottom: 4px; }
.modal-help code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 11.5px;
    background: #e9edf5;
    padding: 1px 6px;
    border-radius: 5px;
    color: var(--text-2);
    border: 1px solid var(--line);
}

@media (max-width: 880px) {
    .modal.modal-lg { max-width: 560px; }
    .modal.modal-mid { max-width: 560px; }
    .acct-list { grid-template-columns: 1fr; }
    .modal-body.cols { grid-template-columns: 1fr; column-gap: 0; max-height: 74vh; }
    /* 单列时不需要中缝的线和留白 */
    .modal-body.cols > .mcol + .mcol {
        padding-left: 0;
        border-left: none;
        margin-top: 6px;
    }
}
.modal-foot {
    padding: 15px 22px;
    border-top: 1px solid var(--line);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ================= 供应商分组（模型接入页） ================= */
.provider-group { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 18px; overflow: hidden; background: var(--panel); box-shadow: var(--shadow-sm); transition: box-shadow .2s, border-color .2s; }
.provider-group:hover { box-shadow: var(--shadow-md); border-color: color-mix(in srgb, var(--brand) 22%, var(--line)); }
.provider-head {
    display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
    padding: 15px 20px; background: linear-gradient(180deg, #f7f8fd, #f4f5fb); border-bottom: 1px solid var(--line);
}
.provider-head .ph-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.provider-head .ph-name { font-weight: 700; font-size: 14px; color: var(--text); }
.provider-head .ph-url { color: var(--muted); font-size: 12px; font-family: ui-monospace, Menlo, monospace; }
.provider-head .ph-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.provider-group.disabled { opacity: .6; }

/* ================= 在线测试 ================= */
.chat-box { display: flex; flex-direction: column; height: 66vh; min-height: 400px; }
.chat-log { flex: 1; overflow-y: auto; padding: 8px 6px; display: flex; flex-direction: column; gap: 15px; }
.bubble { max-width: 82%; animation: riseIn .3s var(--ease) backwards; }
.bubble .who { font-size: 11.5px; color: var(--muted); margin-bottom: 5px; font-weight: 600; }
.bubble .body {
    padding: 12px 15px;
    border-radius: 16px;
    background: var(--panel-2);
    border: 1px solid var(--line);
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.6;
}
.bubble.me { margin-left: auto; }
.bubble.me .who { text-align: right; }
.bubble.me .body {
    background: var(--brand-grad);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 4px 14px -4px rgba(124, 92, 255, .5);
}
.bubble .meta { font-size: 11.5px; color: var(--muted); margin-top: 5px; }
.chat-input { display: flex; gap: 10px; margin-top: 14px; align-items: flex-end; }
.chat-input textarea { flex: 1; height: 50px; border-radius: var(--radius-sm); }

/* 覆盖层级说明块 */
.hier { display: flex; flex-direction: column; gap: 8px; margin: 4px 0 0; }
.hier .tier { display: flex; align-items: center; gap: 10px; padding: 10px 13px; border-radius: var(--radius-sm); background: var(--panel-2); border: 1px solid var(--line); font-size: 12.5px; transition: border-color .15s; }
.hier .tier:hover { border-color: color-mix(in srgb, var(--brand) 30%, var(--line)); }
.hier .tier .n { width: 21px; height: 21px; flex: 0 0 21px; border-radius: 50%; background: var(--brand-grad); color: #fff; display: grid; place-items: center; font-size: 11px; font-weight: 700; box-shadow: 0 2px 6px -1px rgba(124,92,255,.5); }
.hier .tier b { font-weight: 600; }
.hier .tier span { color: var(--muted); }

/* 模型备注：价格段高亮，其余说明弱化 */
.price-tag { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.note-rest { color: var(--muted); margin-left: 6px; font-size: 12.5px; }

/* ================= SweetAlert2（本地 vendor）微调 ================= */
/* toast 默认贴顶，会盖住吸顶 page-head 右上角的按钮，往下压到标题栏之下 */
.swal2-container.swal2-top-end { padding-top: 88px; padding-right: 22px; }
.swal2-container.swal2-top-end .swal2-toast { max-width: 420px; border-radius: 12px; }
.swal2-popup { font-family: inherit; border-radius: 18px; }
.swal2-title { font-size: 17px; font-weight: 700; }
.swal2-html-container { font-size: 13.5px; line-height: 1.65; }
.swal2-actions button { font-family: inherit; border-radius: 9px; }

/* ================= 音色页：滑块与试听 ================= */
/* 语速 / 音调 / 音量三个滑块的共同结构。全局 input 有 padding + border，
   range 必须显式清掉，否则会被撑成一个带边框的长条。 */
.slider-field { margin-bottom: 17px; }
.slider-field > span {
    display: block;
    font-size: 12.5px;
    color: var(--text-2);
    font-weight: 600;
    margin-bottom: 8px;
}
.slider-field > span b {
    color: var(--brand);
    font-variant-numeric: tabular-nums;
    margin-left: 4px;
    font-weight: 700;
}
.slider-field > small {
    display: block;
    color: var(--muted);
    font-size: 11.5px;
    margin-top: 6px;
    line-height: 1.5;
}
.slider-field input[type="range"] {
    width: 100%;
    height: 22px;
    padding: 0;
    border: none;
    background: transparent;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}
.slider-field input[type="range"]:focus { outline: none; box-shadow: none; }
.slider-field input[type="range"]::-webkit-slider-runnable-track {
    height: 5px;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--brand), var(--brand-2) var(--pos, 50%), var(--line-strong) var(--pos, 50%));
}
.slider-field input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    margin-top: -6.5px;
    border-radius: 50%;
    background: #fff;
    border: 2.5px solid var(--brand);
    box-shadow: 0 2px 6px rgba(20, 26, 44, .25);
    transition: transform .12s, box-shadow .12s;
}
.slider-field input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.12); }
.slider-field input[type="range"]:focus-visible::-webkit-slider-thumb {
    box-shadow: 0 0 0 4px var(--brand-ring);
}
.preview-row { display: flex; align-items: center; gap: 10px; margin: 4px 0 2px; }
.preview-row .hint { margin: 0; }

/* 机器人列表里的语音开关：表格单元格要垂直居中，别被 22px 的开关撑歪 */
.voice-cell { display: flex; align-items: center; gap: 8px; }
.voice-cell .saved-tip { font-size: 11px; }

/* 响应式：窄屏折叠边栏为顶栏 */
@media (max-width: 820px) {
    .layout { flex-direction: column; }
    .sidebar { width: 100%; flex: none; height: auto; position: static; border-right: none; border-bottom: 1px solid var(--line); }
    .brand { padding: 14px 16px 10px; }
    /* 窄屏顶栏导航：允许换行成两行，避免菜单项被右侧裁断 */
    .nav { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 14px 12px; overflow-x: visible; }
    .nav .group-label { display: none; }
    .nav a { margin: 0; white-space: nowrap; padding: 8px 11px; }
    .nav a:hover { transform: none; }
    .nav a.active::before { display: none; }
    .sidebar-foot { display: none; }
    .content, .page-head, .flash-wrap { padding-left: 18px; padding-right: 18px; }
    .page-head { padding-top: 18px; }
}
/* 「从中转站导入模型」弹窗（models.html #import_modal）
   一行一个模型：勾选框 · 名称/ID · 价格备注。已导入的置灰不可勾，
   中转站标记停用的划掉。清单在弹窗体内滚动，不顶高页面。 */
.import-toolbar {
    display: flex; align-items: center; gap: 14px;
    margin-bottom: 10px; font-size: 12.5px; color: var(--text-2);
}
.import-toolbar .grow { flex: 1; min-width: 0; text-align: right; color: var(--muted); font-size: 12px; }
.import-check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; white-space: nowrap; }
.import-check input { accent-color: var(--brand); width: 14px; height: 14px; margin: 0; cursor: pointer; }
.import-list {
    border: 1px solid var(--line); border-radius: var(--radius-sm);
    background: var(--panel-2); overflow: hidden; max-height: 46vh; overflow-y: auto;
}
.import-row {
    display: grid; grid-template-columns: auto minmax(0, 1fr) minmax(0, .95fr);
    align-items: center; gap: 12px; padding: 9px 14px;
    border-bottom: 1px solid var(--line); cursor: pointer; transition: background .12s;
}
.import-row:last-child { border-bottom: none; }
.import-row:hover { background: var(--panel); }
.import-row input[type=checkbox] { accent-color: var(--brand); width: 15px; height: 15px; margin: 0; cursor: pointer; }
.import-row .cell-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.import-row .cell-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.import-row .import-note {
    font-size: 11.5px; color: var(--text-2); text-align: right;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.import-row.is-exists { opacity: .55; cursor: default; }
.import-row.is-exists .import-note { color: var(--ok); }
.import-row.is-exists:hover { background: transparent; }
.import-row.is-off .cell-title { text-decoration: line-through; color: var(--muted); }
.import-row.is-off .import-note { color: var(--warn); }

@media (max-width: 820px) {
    .import-row { grid-template-columns: auto minmax(0, 1fr); }
    .import-row .import-note { display: none; }
}

/* ==================================================================
   模板扩展层
   通用后台要用的几块：导航分组、筛选栏 flex、分页、趋势图、
   行内操作列、弹窗两列栅格、主题色板。
   上面是原项目的业务样式，这一段是可复用部分的补充。
   ================================================================== */

/* 卡片顶部高光跟随主题色 */
.card::before {
    background: linear-gradient(90deg, var(--brand), var(--brand-2), transparent 92%);
}

/* ---------- 侧边栏分组标题 ---------- */
.nav-label {
    padding: 16px 14px 7px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--muted);
    opacity: .75;
    user-select: none;
}
.nav-label:first-child { padding-top: 6px; }

/* ---------- 筛选栏：控件数量不固定，用 flex 而不是固定栅格 ---------- */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}
.filter-bar input[type="search"] { flex: 0 1 300px; width: 300px; max-width: 100%; }
.filter-bar select { flex: 0 1 150px; width: 150px; }
.filter-bar .btn { height: 32px; display: inline-flex; align-items: center; }

/* ---------- 表头对齐 ---------- */
th { white-space: nowrap; }
th[data-align="right"] { text-align: right; }
th[data-align="center"] { text-align: center; }

/* ---------- 行内操作列 ---------- */
td.row-actions { text-align: right; white-space: nowrap; }
td.row-actions button { margin-left: 6px; }

/* ---------- 分页 ---------- */
.pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 2px 2px 6px;
}
.pager-info { font-size: 12.5px; color: var(--muted); }
.pager-info b { color: var(--text-2); font-weight: 600; }
.pager-btns { display: flex; align-items: center; gap: 6px; }
.pager-btns .btn { min-width: 34px; padding: 5px 10px; }
.pager-gap { color: var(--muted); padding: 0 2px; }
.btn.disabled { opacity: .4; pointer-events: none; box-shadow: none; }

/* ---------- 总览页 7 天趋势 ---------- */
.trend {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    height: 150px;
    padding: 20px 2px 0;
}
.trend-col {
    flex: 1;
    height: 100%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    gap: 9px;
}
.trend-bar {
    width: 100%;
    max-width: 54px;
    min-height: 3px;
    border-radius: 9px 9px 4px 4px;
    background: var(--brand-grad);
    opacity: .88;
    position: relative;
    display: flex;
    justify-content: center;
    transition: height .45s var(--ease), opacity .2s;
}
.trend-bar:hover { opacity: 1; }
.trend-bar span {
    position: absolute;
    top: -20px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-2);
}
.trend-label { font-size: 11.5px; color: var(--muted); white-space: nowrap; }

/* ---------- 弹窗表单：两列栅格，长文本与开关独占一行 ---------- */
#modal_body { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
#modal_body .field { margin-bottom: 14px; }
#modal_body .switch-row { margin-bottom: 8px; }
#modal_body .full { grid-column: 1 / -1; }
@media (max-width: 620px) { #modal_body { grid-template-columns: 1fr; } }

/* ---------- 主题色板 ---------- */
.swatches { display: flex; gap: 9px; flex-wrap: wrap; margin: 2px 0 18px; }
.swatches button {
    width: 40px;
    height: 30px;
    padding: 0;
    border-radius: 9px;
    border: 1px solid rgba(20, 26, 44, .08);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
}
.swatches button:hover { transform: translateY(-2px); }

/* 原生取色器：默认会被 input 的 width:100% 拉成一条长色带，这里收窄 */
.color-row { display: flex; align-items: center; gap: 10px; }
.color-input {
    width: 84px !important;
    height: 38px !important;
    padding: 3px !important;
    border-radius: 10px !important;
    cursor: pointer;
    flex: none;
}
.color-row code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
    color: var(--muted);
    background: var(--panel-3);
    padding: 3px 8px;
    border-radius: 6px;
}

/* ---------- 空态在表格内更紧凑 ---------- */
td.empty { padding: 40px 16px; }

/* ------------------------------------------------------------------
   主题色收口
   原样式里有几处把品牌色写死了（#4f46e5 / #7c5cff 之类），
   换主题后会出现「换了一半」的割裂感。这里统一改成 CSS 变量。
   ------------------------------------------------------------------ */

.nav a.active {
    background: var(--brand-soft);
    color: var(--brand);
    box-shadow: inset 0 0 0 1px var(--brand-ring);
}
.nav a.active::before { box-shadow: 0 0 8px var(--brand-ring); }

/* 注意：background 简写会把 background-clip 重置成 border-box，
   所以这里必须把裁切属性一起重写，否则标题会变成一整块色带 */
.page-head h1 {
    background: linear-gradient(90deg, var(--text), var(--brand));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-foot { background: linear-gradient(180deg, transparent, var(--brand-soft)); }

/* 统计块统一走品牌渐变：原来按位置分配六种固定色，换主题后不协调 */
.grid.stats .stat:nth-child(1),
.grid.stats .stat:nth-child(2),
.grid.stats .stat:nth-child(3),
.grid.stats .stat:nth-child(4),
.grid.stats .stat:nth-child(5),
.grid.stats .stat:nth-child(6) {
    --accent: var(--brand);
    --accent-grad: var(--brand-grad);
}
