/* ===== 沙琪玛开放平台 ===== */
:root {
  --brand: #6366F1; --brand-2: #8B5CF6;
  --bg: #f6f7f9; --bg-panel: #ffffff; --bg-side: #1f232b; --bg-side-hover: #2c313b;
  --text: #1f2329; --text-2: #6b7280; --text-side: #c8cdd5;
  --border: #e5e7eb; --shadow: 0 2px 12px rgba(0,0,0,.06);
  --green: #18a058; --red: #e5484d;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text);
}
#app { display: flex; min-height: 100vh; }

/* ---------- 侧边导航 ---------- */
#sidebar {
  width: 240px; min-width: 240px; background: var(--bg-side); color: var(--text-side);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.p-brand { display: flex; align-items: center; gap: 12px; padding: 22px 20px 18px; }
.p-logo {
  width: 42px; height: 42px; border-radius: 12px; color: #fff; font-weight: 700; font-size: 20px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  overflow: hidden; padding: 0;
}
.p-logo img { width: 100%; height: 100%; display: block; }
.p-title { font-size: 17px; font-weight: 700; color: #fff; }
.p-sub { font-size: 12px; color: var(--text-side); opacity: .75; }
#nav { flex: 1; padding: 8px 12px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; margin: 2px 0;
  border-radius: 10px; color: var(--text-side); text-decoration: none; font-size: 14px;
  cursor: pointer; transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--bg-side-hover); color: #fff; }
.nav-item.active { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; font-weight: 500; }
.p-foot { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,.08); }
.back-chat { color: var(--text-side); text-decoration: none; font-size: 13px; display: block; margin-bottom: 8px; }
.back-chat:hover { color: #fff; }
.p-ver { font-size: 11px; opacity: .5; }

/* ---------- 主内容 ---------- */
#main { flex: 1; padding: 32px 36px; min-width: 0; max-width: 1200px; }
.page { display: none; animation: fadeIn .2s; }
.page.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; } }
h1 { font-size: 24px; margin-bottom: 6px; }
.page-desc { color: var(--text-2); font-size: 14px; margin-bottom: 24px; }

/* 统计卡片 */
.card-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.stat-card {
  background: var(--bg-panel); border-radius: 14px; padding: 18px 20px; box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.stat-card .sc-label { font-size: 13px; color: var(--text-2); margin-bottom: 8px; }
.stat-card .sc-value { font-size: 26px; font-weight: 700; letter-spacing: .5px; }
.stat-card .sc-sub { font-size: 12px; color: var(--text-2); margin-top: 6px; }
.stat-card.accent { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; border: none; }
.stat-card.accent .sc-label, .stat-card.accent .sc-sub { color: rgba(255,255,255,.85); }

/* 面板 */
.panel {
  background: var(--bg-panel); border-radius: 14px; padding: 20px; box-shadow: var(--shadow);
  border: 1px solid var(--border); margin-bottom: 20px;
}
.panel-row { display: flex; gap: 20px; }
.panel.half { flex: 1; min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.panel-head h3 { font-size: 15.5px; }
.legend { font-size: 12px; color: var(--text-2); }
.lg { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin: 0 4px 0 10px; }
.lg.p { background: var(--brand); } .lg.c { background: var(--brand-2); }

/* 图表 */
.chart-box { min-height: 180px; }
.chart-box svg { display: block; width: 100%; height: auto; }
.flex-center { display: flex; align-items: center; justify-content: center; gap: 24px; flex-wrap: wrap; }
.pie-legend { font-size: 13px; }
.pie-legend .pl-item { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.pie-legend .pl-dot { width: 12px; height: 12px; border-radius: 4px; }
.pie-legend .pl-val { color: var(--text-2); margin-left: auto; padding-left: 16px; }
.bar-tip { font-size: 11px; fill: var(--text-2); }
.bar-x { font-size: 11px; fill: var(--text-2); }
.empty-tip { color: var(--text-2); font-size: 13px; text-align: center; padding: 40px 0; }

/* 表格 */
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: left; padding: 10px 12px; background: #fafbfc; color: var(--text-2); font-weight: 500; border-bottom: 1px solid var(--border); }
.tbl td { padding: 10px 12px; border-bottom: 1px solid #f0f1f3; }
.tbl tr:hover td { background: #fafbfc; }
.tbl code { background: #f0f1f3; padding: 2px 8px; border-radius: 5px; font-size: 12.5px; }
.doc h3 { margin: 22px 0 10px; font-size: 15.5px; }
.doc h3:first-child { margin-top: 0; }
.doc .code {
  background: #282c34; color: #e6e6e6; padding: 14px 16px; border-radius: 10px;
  font-size: 13px; line-height: 1.7; overflow-x: auto; margin: 8px 0;
  font-family: "Cascadia Code", Consolas, monospace;
}

/* 按钮/控件 */
.btn-primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; border: none;
  padding: 8px 18px; border-radius: 9px; font-size: 13.5px; cursor: pointer; transition: opacity .15s, transform .1s;
}
.btn-primary:hover { opacity: .9; transform: translateY(-1px); }
.btn-sm {
  background: #f0f1f3; border: 1px solid var(--border); padding: 5px 12px; border-radius: 7px;
  font-size: 12.5px; cursor: pointer; color: var(--text);
}
.btn-sm:hover { background: #e8eaee; }
.btn-danger { color: var(--red); }
.sel {
  padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px;
  background: #fff; color: var(--text); outline: none;
}
.pager { display: flex; align-items: center; gap: 14px; justify-content: center; margin-top: 14px; font-size: 13px; color: var(--text-2); }
.tag { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; }
.tag.green { background: #e7f6ee; color: var(--green); }
.tag.gray { background: #f0f1f3; color: var(--text-2); }
.key-reveal {
  display: flex; align-items: center; gap: 12px; background: #fafbfc; border: 1px dashed var(--brand);
  padding: 14px 16px; border-radius: 10px; margin-bottom: 10px;
}
.key-reveal code { font-size: 14px; color: var(--brand); font-weight: 600; letter-spacing: .5px; }
.warn { color: var(--red); font-size: 13px; }

/* 模型卡片 */
.model-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 18px; }
.model-card { background: var(--bg-panel); border-radius: 14px; padding: 22px; box-shadow: var(--shadow); border: 1px solid var(--border); }
.model-card .mc-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.model-card .mc-logo {
  width: 44px; height: 44px; border-radius: 12px; color: #fff; font-weight: 700; font-size: 19px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
}
.model-card .mc-name { font-size: 17px; font-weight: 700; }
.model-card .mc-engine { font-size: 12px; color: var(--text-2); }
.model-card .mc-rows { font-size: 13.5px; }
.model-card .mc-row { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid #f0f1f3; }
.model-card .mc-row:last-child { border: none; }
.model-card .mc-row .k { color: var(--text-2); }
.model-card .mc-caps { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 6px; }
.model-card .cap { background: #fdf1e0; color: var(--brand); font-size: 12px; padding: 3px 10px; border-radius: 999px; }

/* 记忆库 */
.mem-add { display: flex; gap: 10px; margin-bottom: 16px; }
.mem-add input {
  flex: 1; padding: 10px 14px; border: 1px solid var(--border); border-radius: 9px; font-size: 14px; outline: none;
}
.mem-add input:focus { border-color: var(--brand); }
.mem-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: #fafbfc;
  border-radius: 9px; margin-bottom: 8px; font-size: 14px;
}
.mem-item .mi-text { flex: 1; }
.mem-item .mi-time { font-size: 12px; color: var(--text-2); }
.switch { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); cursor: pointer; }
.switch input { display: none; }
.switch .sl {
  width: 38px; height: 21px; border-radius: 999px; background: #d8dbe0; position: relative; transition: background .2s;
}
.switch .sl::after {
  content: ""; position: absolute; width: 17px; height: 17px; border-radius: 50%; background: #fff;
  top: 2px; left: 2px; transition: left .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.switch input:checked + .sl { background: var(--brand); }
.switch input:checked + .sl::after { left: 19px; }

/* Playground */
.pg-config { display: flex; gap: 20px; margin-bottom: 14px; font-size: 13.5px; align-items: center; }
.pg-config label { display: flex; align-items: center; gap: 8px; }
.pg-config .sel { min-width: 90px; }
#pg-input {
  width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px;
  font-size: 14px; font-family: inherit; resize: vertical; outline: none;
}
#pg-input:focus { border-color: var(--brand); }
.pg-actions { display: flex; align-items: center; gap: 14px; margin: 12px 0; }
.pg-status { font-size: 13px; color: var(--text-2); }
.pg-output {
  background: #282c34; color: #e6e6e6; padding: 16px; border-radius: 10px; min-height: 120px;
  font-size: 13.5px; line-height: 1.7; white-space: pre-wrap; word-break: break-word;
  font-family: "Cascadia Code", Consolas, monospace;
}

@media (max-width: 900px) {
  #sidebar { width: 70px; min-width: 70px; }
  #sidebar .p-title, #sidebar .p-sub, #sidebar .nav-item span, .p-foot { display: none; }
  .nav-item { justify-content: center; font-size: 18px; }
  #main { padding: 20px; }
  .card-grid { grid-template-columns: 1fr 1fr; }
  .panel-row { flex-direction: column; }
}

/* ===== 深色主题 ===== */
body.dark { --bg: #0B0F14; --bg-panel: #111820; --bg-side: #080C11; --bg-side-hover: #15202B; --text: #e6e8eb; --text-2: #9aa1ac; --border: #1F2A36; --shadow: 0 2px 12px rgba(0,0,0,.4); }
body.dark .panel, body.dark .card, body.dark .stat-card { background: var(--bg-panel); border-color: var(--border); }
body.dark input, body.dark select, body.dark textarea { background: #14171c; color: var(--text); border-color: var(--border); }
body.dark .tbl th { color: var(--text-2); border-color: var(--border); }
body.dark .tbl td { border-color: var(--border); }
body.dark .empty-tip { color: var(--text-2); }

/* ===== 侧栏工具按钮 ===== */
.p-tools { display: flex; gap: 8px; margin-bottom: 10px; }
.p-tools .icon-btn { background: var(--bg-side-hover); border: none; color: var(--text-side); width: 34px; height: 34px; border-radius: 8px; cursor: pointer; font-size: 16px; display: flex; align-items: center; justify-content: center; }
.p-tools .icon-btn:hover { background: var(--brand); color: #fff; }

/* ===== 弹窗 ===== */
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal { background: var(--bg-panel); border: 1px solid var(--border); border-radius: 14px; padding: 22px; width: 420px; max-width: 92vw; box-shadow: var(--shadow); }
.modal h3 { margin: 0 0 14px; }
.modal label { display: block; font-size: 12.5px; color: var(--text-2); margin: 10px 0 4px; }
.modal input, .modal select { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13.5px; box-sizing: border-box; background: var(--bg); color: var(--text); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.am-status { margin-top: 10px; font-size: 13px; color: var(--text-2); min-height: 18px; }

/* ===== 下载中心 ===== */
.dl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.dl-card { background: var(--bg-panel); border: 1px solid var(--border); border-radius: 14px; padding: 22px; text-align: center; box-shadow: var(--shadow); }
.dl-card .dl-icon { font-size: 40px; margin-bottom: 8px; }
.dl-card .dl-name { font-weight: 700; font-size: 15.5px; margin-bottom: 4px; }
.dl-card .dl-file { font-size: 12px; color: var(--text-2); word-break: break-all; margin-bottom: 6px; }
.dl-card .dl-size { font-size: 12.5px; color: var(--text-2); margin-bottom: 12px; }
.dl-card .btn-primary { text-decoration: none; display: inline-block; padding: 8px 22px; }

/* ===== 渠道列表 ===== */
.ch-row { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--border); font-size: 13px; flex-wrap: wrap; }
.ch-row:last-child { border-bottom: none; }
.ch-name { font-weight: 600; min-width: 140px; }
.ch-url { color: var(--text-2); font-size: 12px; }
.ch-models { color: var(--brand); font-size: 12px; font-weight: 600; }
.sec-title { margin: 18px 0 10px; }


/* ===== SVG 图标系统 ===== */
.ico { vertical-align: -2.5px; flex-shrink: 0; }
.nav-item .ico { margin-right: 4px; }
.nav-item { display: flex; align-items: center; gap: 2px; }
.mc-logo img { width: 100%; height: 100%; border-radius: inherit; display: block; }
.dl-icon { color: var(--brand); }


/* ===== v2 用户体系/管理后台 ===== */
.grid-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .grid-2col { grid-template-columns: 1fr; } }
.input { padding: 8px 12px; border: 1px solid var(--border, #d9dee3); border-radius: 8px; font-size: 13px; background: var(--panel, #fff); color: var(--text, #1a1d21); outline: none; }
.input:focus { border-color: #6366F1; }
.card { margin-bottom: 0; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.tag-free { background: #eef1f4; color: #8B93A7; }
.tag-vip { background: rgba(99,102,241,.15); color: #6366F1; }
.tag-svip { background: rgba(255,179,71,.18); color: #d99000; }
.tag-ok { background: rgba(99,102,241,.15); color: #6366F1; }
.tag-off { background: rgba(229,72,77,.12); color: #e5484d; }
body.dark .tag-free { background: #1e2f27; }
.chan-card { border: 1px solid var(--border, #d9dee3); border-radius: 12px; padding: 16px; margin-bottom: 12px; }
.chan-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.chan-name { font-weight: 700; font-size: 15px; }
.chan-status { font-size: 12px; color: #8a919c; }
textarea.cfg { width: 100%; min-height: 110px; font-family: monospace; font-size: 12px; padding: 10px; border: 1px solid var(--border, #d9dee3); border-radius: 8px; background: var(--panel, #fff); color: var(--text, #1a1d21); margin-top: 8px; }

/* ===== ��������������uxbot �磩 ===== */
.acct-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.acct-avatar { width: 46px; height: 46px; border-radius: 13px; background: linear-gradient(135deg, #6366F1, #8B5CF6); display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 19px; flex-shrink: 0; }
.acct-name { font-weight: 700; font-size: 15.5px; }
.acct-sub { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.acct-plan-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.acct-plan-desc { font-size: 12px; color: var(--text-2); }
.acct-balance { font-size: 34px; font-weight: 700; background: linear-gradient(135deg, #6366F1, #8B5CF6); -webkit-background-clip: text; background-clip: text; color: transparent; margin: 8px 0; }
.ctx-track { background: rgba(128,128,128,.18); border-radius: 8px; height: 10px; overflow: hidden; margin: 8px 0; }
.ctx-fill { height: 100%; width: 0; background: linear-gradient(90deg, #6366F1, #8B5CF6); transition: width .4s ease; }

/* ===== ���������ʸ����� ===== */
.dl-card { transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease; }
.dl-card:hover { transform: translateY(-3px); border-color: #6366F1; box-shadow: 0 8px 24px rgba(99,102,241,.18); }
.dl-card .dl-icon { display: inline-flex; align-items: center; justify-content: center; width: 64px; height: 64px; border-radius: 16px; background: linear-gradient(135deg, rgba(99,102,241,.14), rgba(139,92,246,.14)); color: #6366F1; margin-bottom: 12px; }
/* ===== 下载中心 v2（2026-09-02）：安装版标记 ===== */
.dl-badge { position: absolute; top: 10px; right: 10px; background: #6366F1; color: #fff; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 6px; }
.dl-card { position: relative; }
.dl-desc { font-size: 12px; color: var(--text-2); margin: 2px 0 8px; line-height: 1.5; }
.dl-setup-btn { background: linear-gradient(135deg, #1a1a1a, #333); }
.dl-card .dl-setup-btn:hover { background: #333; }
