/* =========================================================
   多聚AI — 控制台的通用组件（照 spiderai.fun 控制台的版式：页头、统计条、面板、工具栏、下拉、表格、空状态、表单……）
   全部带 cx- 前缀，不会和原来的 style.css（.btn / .card / .tabs / .stat …）互相影响。
   颜色都用 console-crt.css 里的变量（--ink / --line / --surface / --accent …），深色浅色自动跟着变。
   各页面自己的样式放在 con-<页面>.css 里
   ========================================================= */
:root, :root:not([data-theme="light"]) {
  --ok: #5fc995; --ok-soft: rgba(95, 201, 149, .12); --warn-soft: rgba(230, 172, 76, .12);
  --err: #ff6f61; --err-soft: rgba(255, 111, 97, .12); --accent-soft: rgba(224, 133, 92, .13);
}
:root[data-theme="light"] {
  --ok: #18865a; --ok-soft: rgba(24, 134, 90, .1); --warn-soft: rgba(156, 100, 0, .1);
  --err: #c4352b; --err-soft: rgba(196, 53, 43, .09); --accent-soft: rgba(194, 96, 58, .1);
}

/* ---------- 文字 ---------- */
.cx-muted { color: var(--ink-3); }
.cx-px { font-family: var(--px); font-weight: 400; letter-spacing: .02em; }
.cx-lnk { color: var(--accent); text-decoration: underline; text-decoration-color: var(--accent-line); text-underline-offset: 3px; cursor: pointer; }
.cx-lnk:hover { text-decoration-color: var(--accent); }
.cx-kbd { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; border: 1px solid var(--line-2); border-radius: 5px; font: 500 11px/1 var(--mono); color: var(--ink-3); }
@media (hover: none) { .cx-kbd { display: none; } }

/* ---------- 按钮 ---------- */
.cx-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px;
  border: 1px solid var(--line-2); border-radius: 9px; background: var(--surface); color: var(--ink);
  font: 550 14px var(--font); white-space: nowrap; cursor: pointer; text-decoration: none;
  transition: background .15s, border-color .15s, color .15s, transform .15s;
}
.cx-btn:hover { background: var(--hover); border-color: var(--ink-3); color: var(--ink); }
.cx-btn:active { transform: translateY(1px); }
.cx-btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.cx-btn svg.icon { width: 16px; height: 16px; }
.cx-btn--pri { background: var(--pri-bg); border-color: var(--pri-bg); color: var(--pri-ink); }
.cx-btn--pri:hover { background: var(--pri-hov); border-color: var(--pri-hov); color: var(--pri-ink); }
.cx-btn--danger { background: var(--err); border-color: var(--err); color: #fff; }
.cx-btn--danger:hover { filter: brightness(.92); background: var(--err); color: #fff; }
.cx-btn--ghost { background: transparent; border-color: transparent; }
.cx-btn--ghost:hover { background: var(--hover); border-color: transparent; }
.cx-btn--sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 8px; gap: 6px; }
.cx-btn--lg { height: 48px; padding: 0 22px; font-size: 15px; border-radius: 11px; }
.cx-btn--block { width: 100%; }
.cx-btn--pri .cx-kbd { border-color: color-mix(in srgb, var(--pri-ink) 35%, transparent); color: inherit; opacity: .75; margin-right: -6px; }
.cx-ib { display: inline-grid; place-items: center; width: 34px; height: 34px; flex: none; border: 0; border-radius: 8px; background: none; color: var(--ink-2); cursor: pointer; transition: background .15s, color .15s; }
.cx-ib:hover, .cx-ib[aria-expanded="true"] { background: var(--hover); color: var(--ink); }
.cx-ib--s { width: 28px; height: 28px; border-radius: 7px; }
.cx-ib svg.icon { width: 16px; height: 16px; }

/* ---------- 页头 ---------- */
.cx-ph { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.cx-ph h1 { margin: 0; font-size: 34px; line-height: 1.15; font-weight: 560; letter-spacing: -.03em; }
.cx-ph p { margin: 6px 0 0; color: var(--ink-2); max-width: 60ch; }
.cx-ph__a { display: flex; gap: 8px; flex: none; flex-wrap: wrap; }
.cx-ln { display: block; overflow: hidden; padding-bottom: .1em; margin-bottom: -.1em; }
.cx-ln > span { display: inline-block; animation: cx-up .7s var(--ease) .08s both; }
@keyframes cx-up { from { transform: translateY(105%); } }

/* ---------- 统计条（一张卡片里横排几个数字） ---------- */
.cx-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 16px; background: var(--surface); overflow: hidden; }
.cx-stats--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cx-stats--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cx-stat { padding: 20px 22px; min-width: 0; }
.cx-stat + .cx-stat { border-left: 1px solid var(--line); }
.cx-stat__k { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-3); }
.cx-stat__k svg.icon { width: 15px; height: 15px; }
.cx-stat__v { margin-top: 14px; font: 400 44px/1 var(--px); letter-spacing: .01em; text-shadow: var(--glow); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cx-stat__v small { font-family: var(--font); font-size: 14px; font-weight: 500; color: var(--ink-3); letter-spacing: 0; margin-left: 2px; text-shadow: none; }
.cx-stat__s { margin-top: 6px; font-size: 12.5px; color: var(--ink-3); }
.cx-stat__s .up { color: var(--ok); } .cx-stat__s .dn { color: var(--err); }

/* ---------- 面板 / 布局 ---------- */
.cx-panel { border: 1px solid var(--line); border-radius: 16px; background: var(--surface); min-width: 0; }
.cx-panel__h { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.cx-panel__h h2, .cx-panel__h h3 { margin: 0; font-size: 15px; font-weight: 600; }
.cx-panel__b { padding: 20px; }
.cx-sp { flex: 1; }
.cx-stack { display: grid; gap: 20px; }
.cx-cols { display: grid; gap: 20px; margin-top: 20px; }
.cx-cols--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cx-cols--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cx-cols--21 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.cx-row { display: flex; align-items: center; gap: 16px; }
.cx-row > div { flex: 1; min-width: 0; }
.cx-row b { display: block; font-weight: 600; }
.cx-row small { display: block; margin-top: 2px; color: var(--ink-3); font-size: 13px; }
.cx-big { font: 400 40px/1 var(--px); text-shadow: var(--glow); font-variant-numeric: tabular-nums; }
.cx-dl { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px 20px; margin: 0; font-size: 14px; }
.cx-dl dt { color: var(--ink-3); }
.cx-dl dd { margin: 0; text-align: right; font-weight: 550; }

/* ---------- 空状态 / 占位 ---------- */
.cx-empty { display: grid; justify-items: center; padding: 64px 24px 72px; text-align: center; }
.cx-empty__i { display: grid; place-items: center; width: 48px; height: 48px; margin-bottom: 16px; border-radius: 12px; background: var(--sunk); color: var(--ink-3); }
.cx-empty__i svg.icon { width: 20px; height: 20px; }
.cx-empty h2 { margin: 0; font-size: 17px; font-weight: 600; }
.cx-empty p { max-width: 40ch; margin: 6px 0 18px; color: var(--ink-2); }
.cx-blank { display: grid; place-items: center; min-height: 220px; color: var(--ink-3); font-size: 13.5px; }

/* ---------- 工具栏 / 搜索 / 下拉 / 分段 / 标签页 ---------- */
.cx-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.cx-search { position: relative; flex: 0 1 320px; min-width: 200px; }
.cx-search > svg.icon { position: absolute; left: 12px; top: 50%; margin-top: -8px; width: 16px; height: 16px; color: var(--ink-3); pointer-events: none; }
.cx-search .cx-inp { padding-left: 38px; padding-right: 38px; }
.cx-search .cx-kbd { position: absolute; right: 10px; top: 50%; margin-top: -10px; pointer-events: none; }
.cx-search .cx-inp:focus ~ .cx-kbd, .cx-search.has-q .cx-kbd { display: none; }
.cx-dd {
  position: relative; display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 10px 0 13px;
  border: 1px solid var(--line-2); border-radius: 9px; background: var(--surface); color: var(--ink); font: 14px var(--font); white-space: nowrap; cursor: pointer;
  transition: border-color .15s;
}
.cx-dd:hover { border-color: var(--ink-3); }
.cx-dd:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.cx-dd__k { color: var(--ink-3); }
.cx-dd.is-on { border-color: var(--accent-line); }
.cx-dd svg.icon { width: 14px; height: 14px; color: var(--ink-3); }
/* 用原生 select 做下拉：盖在整个框上，透明，点击打开系统菜单（键盘、读屏都可用） */
.cx-dd select { position: absolute; inset: 0; width: 100%; opacity: 0; cursor: pointer; font-size: 14px; }
.cx-dd__v { font-weight: 500; }
.cx-seg { position: relative; display: inline-flex; padding: 3px; border-radius: 10px; background: var(--sunk); }
.cx-seg button { height: 30px; padding: 0 12px; border: 0; border-radius: 8px; background: none; color: var(--ink-3); font: 550 13px var(--font); white-space: nowrap; cursor: pointer; transition: color .2s, background .2s; }
.cx-seg button:hover { color: var(--ink); }
.cx-seg button[aria-pressed="true"], .cx-seg button[aria-checked="true"], .cx-seg button.on { color: var(--ink); background: var(--surface); box-shadow: 0 1px 2px rgba(0, 0, 0, .08), 0 0 0 1px var(--line); }
/* 和价格页一样的方括号分段（「按 Token」「按实际消费」这种） */
.cx-bseg { display: inline-flex; gap: 2px; }
.cx-bseg button { position: relative; height: 30px; padding: 0 14px; border: 0; background: none; color: var(--ink-3); font: 550 13px var(--font); cursor: pointer; }
.cx-bseg button:hover, .cx-bseg button[aria-pressed="true"] { color: var(--ink); }
.cx-bseg button[aria-pressed="true"]::before, .cx-bseg button[aria-pressed="true"]::after { position: absolute; top: 50%; transform: translateY(-52%); font: 400 19px/1 var(--px); color: var(--ink-3); }
.cx-bseg button[aria-pressed="true"]::before { content: "["; left: 1px; }
.cx-bseg button[aria-pressed="true"]::after { content: "]"; right: 1px; }
.cx-tabs { position: relative; display: flex; gap: 2px; margin-bottom: 16px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.cx-tab { position: relative; height: 40px; padding: 0 12px; border: 0; background: none; color: var(--ink-3); font: 550 14px var(--font); white-space: nowrap; cursor: pointer; transition: color .15s; }
.cx-tab:hover, .cx-tab[aria-selected="true"] { color: var(--ink); }
.cx-tab[aria-selected="true"]::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--ink); border-radius: 2px; }

/* ---------- 表格 ---------- */
.cx-tframe { position: relative; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); overflow-x: auto; }
.cx-tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.cx-tbl th { height: 44px; padding: 0 12px; text-align: left; font-size: 12.5px; font-weight: 550; color: var(--ink-3); white-space: nowrap; border-bottom: 1px solid var(--line); background: var(--surface); }
.cx-tbl th:first-child, .cx-tbl td:first-child { padding-left: 20px; }
.cx-tbl th:last-child, .cx-tbl td:last-child { padding-right: 20px; }
.cx-tbl td { padding: 16px 12px; vertical-align: middle; border-bottom: 1px solid var(--line); background: var(--surface); transition: background .12s; }
.cx-tbl tbody tr:last-child td { border-bottom: 0; }
.cx-tbl tbody tr:hover td { background: var(--hover); }
.cx-tbl .r { text-align: right; }
.cx-tbl .mono, .cx-mono { font-family: var(--mono); font-size: 13px; }
.cx-tbl .num { font-variant-numeric: tabular-nums; }

/* ---------- 徽标 ---------- */
.cx-badge { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: 999px; background: var(--sunk); font-size: 12px; font-weight: 550; color: var(--ink-2); white-space: nowrap; }
.cx-badge i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.cx-badge--ok { background: var(--ok-soft); color: var(--ok); }
.cx-badge--warn { background: var(--warn-soft); color: var(--warn); }
.cx-badge--err { background: var(--err-soft); color: var(--err); }
.cx-badge--dim { background: var(--sunk); color: var(--ink-3); }

/* ---------- 表单 ---------- */
.cx-fld { display: grid; gap: 7px; margin-bottom: 20px; }
.cx-fld > label, .cx-fld__l { font-size: 13px; font-weight: 550; color: var(--ink-2); }
.cx-fld__h { font-size: 12.5px; color: var(--ink-3); }
.cx-fld__e { font-size: 12.5px; font-weight: 550; color: var(--err); }
.cx-fld--tight { margin-bottom: 0; }
.cx-inp {
  width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: 9px; background: var(--surface); color: var(--ink);
  font: 14px var(--font); transition: border-color .15s, box-shadow .15s;
}
textarea.cx-inp { height: auto; min-height: 88px; padding: 10px 12px; line-height: 1.6; resize: vertical; }
.cx-inp:hover { border-color: var(--ink-3); }
.cx-inp:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.cx-inp::placeholder { color: var(--ink-3); }
.cx-inp.is-err { border-color: var(--err); box-shadow: 0 0 0 3px var(--err-soft); }
.cx-g2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cx-g2 label { display: block; margin-bottom: 5px; font-size: 12.5px; color: var(--ink-3); }

/* ---------- 列表：快捷操作 / 最近活动 / 规则 / 步骤 ---------- */
.cx-qa { display: grid; }
.cx-qa a, .cx-qa button { display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px 20px; border: 0; border-bottom: 1px solid var(--line); background: none; color: var(--ink); text-align: left; text-decoration: none; cursor: pointer; font: inherit; transition: background .15s; }
.cx-qa > :last-child { border-bottom: 0; }
.cx-qa a:hover, .cx-qa button:hover { background: var(--hover); }
.cx-qa__i { display: grid; place-items: center; width: 36px; height: 36px; flex: none; border-radius: 10px; background: var(--sunk); color: var(--ink-2); }
.cx-qa__i svg.icon { width: 16px; height: 16px; }
.cx-qa b { display: block; font-weight: 600; font-size: 14px; }
.cx-qa small { display: block; font-size: 12.5px; color: var(--ink-3); }
.cx-qa .go { margin-left: auto; color: var(--ink-3); }
.cx-act { display: grid; }
.cx-act__r { display: flex; align-items: center; gap: 14px; padding: 13px 20px; border-bottom: 1px solid var(--line); }
.cx-act__r:last-child { border-bottom: 0; }
.cx-act__i { display: grid; place-items: center; width: 32px; height: 32px; flex: none; border-radius: 9px; background: var(--sunk); color: var(--ink-2); }
.cx-act__i svg.icon { width: 15px; height: 15px; }
.cx-act__r > div { flex: 1; min-width: 0; }
.cx-act__r b { display: block; font-weight: 550; font-size: 13.5px; }
.cx-act__r span { font-size: 12.5px; color: var(--ink-3); }
.cx-act__r em { font-style: normal; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ok); }
.cx-rules { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.cx-rules li { display: flex; gap: 10px; color: var(--ink-2); font-size: 13.5px; }
.cx-rules li::before { content: ""; width: 5px; height: 5px; margin-top: 8px; flex: none; border-radius: 50%; background: var(--ink-3); }
.cx-steps { display: grid; margin: 0; padding: 0; list-style: none; counter-reset: st; }
.cx-steps li { position: relative; padding: 0 0 24px 44px; counter-increment: st; color: var(--ink-2); }
.cx-steps li::before { content: counter(st); position: absolute; left: 0; top: 0; width: 28px; height: 28px; border-radius: 50%; background: var(--sunk); color: var(--ink); font-size: 13px; font-weight: 600; display: grid; place-items: center; }

/* ---------- 窄屏 ---------- */
@media (max-width: 1180px) { .cx-cols--21, .cx-cols--3 { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 980px) {
  .cx-cols--2 { grid-template-columns: minmax(0, 1fr); }
  .cx-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cx-stat:nth-child(3) { border-left: 0; }
  .cx-stat:nth-child(n+3) { border-top: 1px solid var(--line); }
}
@media (max-width: 900px) { .cx-ph { flex-direction: column; align-items: flex-start; gap: 16px; } }
@media (max-width: 720px) {
  .cx-search { flex: 1 1 100%; }
  .cx-toolbar .cx-btn--pri { flex: 1; }
  .cx-stats { grid-template-columns: minmax(0, 1fr); }
  .cx-stat + .cx-stat { border-left: 0; border-top: 1px solid var(--line); }
  .cx-ph h1 { font-size: 28px; }
}
