/* ============================================================================
   控制台工作台视觉升级（/console/*）
   ----------------------------------------------------------------------------
   原页面问题：卡片纯白扁平、无层级；侧栏与底同色分不开；指标卡信息弱；
   图表区大片空白；按钮都是纯色方块。
   方案：只重绘「皮肤」，不动 DOM 结构与业务逻辑 —— 统一变量 + 提高信息密度 +
   柔和投影 + 品牌蓝渐变点缀，向主流 AI 聚合控制台（网关/用量/密钥）的观感靠。
   作用域：html.wb-console（由服务端仅对 /console 路由注入）
   ========================================================================== */

.wb-console {
  --wb-bg: #f6f7fb;
  --wb-surface: #ffffff;
  --wb-ink: #0b1220;
  --wb-ink-2: #5b6472;
  --wb-ink-3: #8b93a1;
  --wb-line: #e8ebf2;
  --wb-line-soft: #f0f2f7;
  --wb-blue: #0071e3;
  --wb-violet: #6d5efc;
  --wb-emerald: #0f9d76;
  --wb-amber: #d98324;
  --wb-radius: 18px;
  --wb-ring: 0 0 0 1px rgba(16, 24, 40, 0.06);

  /* 覆写站点 token：整站组件自动跟着变，不必逐个改 */
  --color-background: #f6f7fb;
  --color-void: #f6f7fb;
  --color-abyss: #ffffff;
  --color-sidebar: #ffffff;
  --color-sidebar-foreground: #5b6472;
  --color-sidebar-accent: #eef5ff;
  --color-sidebar-accent-foreground: #0b57c9;
  --color-foreground: #0b1220;
  --color-muted-foreground: #667085;
  --color-muted: #f5f7fb;
  --color-border: #e8ebf2;
  --radius-xl: 18px;
  --radius-lg: 14px;
  --radius-md: 10px;
}

/* ------------------------------------------------------------------ 外壳 */
.wb-console body {
  background: var(--wb-bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* 侧栏：白底 + 发丝分隔，和内容区拉开层次 */
.wb-console .workspace-sidebar-shell {
  background: #fff !important;
  border-right: 1px solid var(--wb-line) !important;
  box-shadow: 1px 0 0 rgba(16, 24, 40, 0.02), 8px 0 28px -24px rgba(16, 24, 40, 0.35);
}
.wb-console .workspace-sidebar-shell > div:first-child {
  border-bottom-color: var(--wb-line-soft) !important;
}

/* 顶栏：半透明毛玻璃，滚动时内容从底下透出来 */
.wb-console .workspace-header-shell {
  background: rgba(255, 255, 255, 0.82) !important;
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid var(--wb-line) !important;
  box-shadow: 0 1px 0 rgba(16, 24, 40, 0.02);
}

/* 主区：极淡的双色光晕，避免大片死白 */
.wb-console main.api-platform-stage {
  background-color: var(--wb-bg) !important;
  background-image:
    radial-gradient(880px 380px at 6% -12%, rgba(0, 113, 227, 0.09), transparent 62%),
    radial-gradient(760px 340px at 96% -8%, rgba(109, 94, 252, 0.08), transparent 64%),
    linear-gradient(180deg, #f8fafe 0%, #f5f7fc 100%);
  background-repeat: no-repeat;
  background-attachment: local;
}

/* 内容收窄居中：宽屏下不再拉满 1400px，阅读更稳 */
.wb-console main.api-platform-stage > div {
  max-width: 1240px;
  margin-inline: auto;
}

/* ---------------------------------------------------------------- 侧栏项 */
.wb-console .sidebar-nav-item {
  min-height: 38px !important;
  padding: 0 10px !important;
  border-radius: 10px !important;
  gap: 10px !important;
  font-size: 13.5px !important;
  font-weight: 500;
  color: var(--wb-ink-2);
  line-height: 1.2;
  transition: background-color 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}
.wb-console .sidebar-nav-item svg {
  width: 17px;
  height: 17px;
  opacity: 0.85;
  stroke-width: 1.8;
}
.wb-console .sidebar-nav-item:hover {
  background: #f5f7fb !important;
  color: var(--wb-ink) !important;
}
.wb-console .sidebar-nav-item:hover svg {
  opacity: 1;
}
/* 当前页：淡蓝底 + 左侧色条 + 蓝色文字，一眼看出位置 */
.wb-console .sidebar-nav-item[aria-current="page"] {
  background: linear-gradient(90deg, #e9f2ff 0%, #f2f8ff 100%) !important;
  color: var(--color-sidebar-accent-foreground) !important;
  font-weight: 600 !important;
  box-shadow: inset 0 0 0 1px rgba(0, 113, 227, 0.12), inset 3px 0 0 0 var(--wb-blue);
}
.wb-console .sidebar-nav-item[aria-current="page"] svg {
  color: var(--wb-blue);
  opacity: 1;
  stroke-width: 2;
}

/* 侧栏分组标题（集成/数据…）统一成小字距标签 */
.wb-console aside [class*="text-[11px]"],
.wb-console aside [class*="text-[10px]"] {
  letter-spacing: 0.04em;
  color: var(--wb-ink-3);
}

/* 侧栏底部：只留一条分隔线，避免「返回主站」和账户卡两条发丝线挤在一起 */
.wb-console .workspace-sidebar-shell > nav[class*="border-t"] {
  border-top-color: transparent !important;
}
.wb-console .workspace-sidebar-shell > div[class*="border-t"] {
  border-top-color: var(--wb-line) !important;
}

/* 侧栏底部账户卡 */
.wb-console aside .rounded-2xl[class*="border"] {
  border-color: var(--wb-line) !important;
  background: #fff;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

/* ---------------------------------------------------------------- 顶栏钮 */
.wb-console .omni-topbar-action,
.wb-console .workspace-header-shell button[class*="size-9"],
.wb-console .workspace-header-shell [data-slot="button"] {
  border-radius: 10px;
  color: var(--wb-ink-2);
  transition: background-color 0.16s ease, color 0.16s ease;
}
.wb-console .omni-topbar-action:hover,
.wb-console .workspace-header-shell button[class*="size-9"]:hover {
  background: #f2f4f9;
  color: var(--wb-ink);
}

/* ------------------------------------------------------------------ 标题 */
.wb-console [data-testid="console-greeting"] {
  font-size: 26px !important;
  font-weight: 700 !important;
  letter-spacing: -0.028em !important;
  color: var(--wb-ink) !important;
  line-height: 1.25 !important;
}

/* 问候区块 → 轻量 hero：浅渐变色块 + 右上角光斑 */
.wb-console .pb-6:has([data-testid="console-greeting"]) {
  position: relative;
  padding: 22px 24px !important;
  margin-bottom: 20px;
  border-radius: var(--wb-radius);
  border: 1px solid rgba(0, 113, 227, 0.1);
  background:
    radial-gradient(520px 200px at 88% -40%, rgba(109, 94, 252, 0.16), transparent 70%),
    radial-gradient(420px 180px at 4% -30%, rgba(0, 113, 227, 0.14), transparent 72%),
    linear-gradient(120deg, #ffffff 0%, #f7faff 55%, #fbf8ff 100%);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 18px 36px -30px rgba(16, 24, 40, 0.5);
  overflow: hidden;
}
.wb-console .pb-6:has([data-testid="console-greeting"]) > div > p {
  margin-top: 8px !important;
  font-size: 13.5px !important;
  color: var(--wb-ink-2) !important;
}

/* -------------------------------------------------------------- 通用卡片 */
.wb-console main section[class*="rounded-[var(--radius-xl)]"],
.wb-console main div[class*="rounded-[var(--radius-xl)]"][class*="bg-card"] {
  border-color: var(--wb-line) !important;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 12px 24px -20px rgba(16, 24, 40, 0.45);
  transition: box-shadow 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

/* ------------------------------------------------------------ 指标卡 */
.wb-console [data-testid="console-metric"] {
  position: relative;
  padding: 18px 20px !important;
  border-radius: var(--wb-radius) !important;
  background-image: radial-gradient(320px 140px at 100% 0%, rgba(0, 113, 227, 0.05), transparent 68%);
  overflow: hidden;
}
.wb-console [data-testid="console-metric"]:hover {
  transform: translateY(-2px);
  border-color: rgba(0, 113, 227, 0.28) !important;
  box-shadow: 0 2px 4px rgba(16, 24, 40, 0.05), 0 22px 36px -26px rgba(0, 113, 227, 0.55);
}

/* 卡头图标：去掉描边框，改成彩色软底方块 */
.wb-console [data-testid="console-metric"] > div:first-child {
  font-size: 12.5px !important;
  font-weight: 600 !important;
  letter-spacing: 0.01em;
  color: var(--wb-ink-2) !important;
}
.wb-console [data-testid="console-metric"] > div:first-child > span:first-child {
  width: 30px;
  height: 30px;
  border-radius: 9px !important;
  border-color: transparent !important;
  background: #eaf2ff;
  color: var(--wb-blue);
}
.wb-console [data-testid="console-metric"] > div:first-child > span:first-child svg {
  width: 15px;
  height: 15px;
  stroke-width: 1.9;
}
.wb-console [data-testid="console-metric"]:nth-child(2) > div:first-child > span:first-child {
  background: #f1eeff;
  color: #6d5efc;
}
.wb-console [data-testid="console-metric"]:nth-child(3) > div:first-child > span:first-child {
  background: #e8f8f1;
  color: #0f9d76;
}
.wb-console [data-testid="console-metric"]:nth-child(4) > div:first-child > span:first-child {
  background: #fff4e6;
  color: #d98324;
}

/* 数值：加大字号 + 收紧字距，成为卡片的视觉焦点 */
.wb-console [data-testid="console-metric"] > div:nth-child(2) {
  font-size: 30px !important;
  font-weight: 700 !important;
  letter-spacing: -0.03em !important;
  line-height: 1.05 !important;
  font-variant-numeric: tabular-nums;
  color: var(--wb-ink) !important;
}
.wb-console [data-testid="console-metric"] > div:nth-child(2) em {
  font-size: 11.5px !important;
  font-weight: 500 !important;
  letter-spacing: 0;
  color: var(--wb-ink-3) !important;
  margin-left: 6px !important;
}

/* 卡底说明 + 迷你趋势缩略图 */
.wb-console [data-testid="console-metric"] > div:nth-child(3) {
  min-height: 26px !important;
  align-items: center !important;
  padding-top: 8px;
  border-top: 1px solid var(--wb-line-soft);
  font-size: 11.5px !important;
  color: var(--wb-ink-3) !important;
}
/* 无数据时缩略图是一条贴底的直线，像残留的下划线：整体压淡，只做背景暗示 */
.wb-console [data-testid="console-metric"] > div:nth-child(3) svg {
  width: 64px;
  opacity: 0.55;
}

/* --------------------------------------------------------- 折线图区域 */
.wb-console [role="img"][aria-label*="趋势"] {
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(0, 113, 227, 0.035) 0%, rgba(255, 255, 255, 0) 60%);
}
.wb-console [role="img"][aria-label*="趋势"] .border-dashed {
  border-color: #edf0f6 !important;
}
/* 空态文案：从"一行灰字"变成带底色的提示条 */
.wb-console [role="img"][aria-label*="趋势"] > .absolute.grid {
  color: var(--wb-ink-3) !important;
  font-size: 12.5px !important;
}
.wb-console [role="img"][aria-label*="趋势"] > .absolute.grid > * {
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px dashed #dfe4ee;
  background: rgba(255, 255, 255, 0.75);
}
.wb-console [data-testid="usage-area-yticks"] {
  color: #a3abba !important;
  font-size: 10.5px !important;
  letter-spacing: 0.02em;
}
/* 零数据时折线是贴底的一条实线（看着像误画的横线）：压淡成基线提示 */
.wb-console [role="img"][aria-label*="趋势"] svg path[stroke] {
  stroke-opacity: 0.4;
}
.wb-console [role="img"][aria-label*="趋势"] svg path[fill^="url"] {
  opacity: 0.55;
}

/* 卡内小标题 */
.wb-console main h2,
.wb-console main h3 {
  letter-spacing: -0.012em;
}

/* ------------------------------------------------------------ 分段控件 */
.wb-console [role="tablist"] [role="tab"] {
  border-radius: 9px !important;
  padding: 5px 11px !important;
  font-size: 12px !important;
  font-weight: 500 !important;
  color: var(--wb-ink-2) !important;
}
.wb-console [role="tablist"] [role="tab"][aria-selected="true"] {
  background: linear-gradient(180deg, #1b87ff 0%, #0071e3 100%) !important;
  color: #fff !important;
  box-shadow: 0 2px 8px -2px rgba(0, 113, 227, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

/* -------------------------------------------------------------- 代码块 */
.wb-console main [class*="color-code-bg"] {
  background: linear-gradient(158deg, #0d1424 0%, #131c31 55%, #0f1728 100%) !important;
  border: 1px solid rgba(255, 255, 255, 0.07) !important;
  border-radius: 16px !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07), 0 24px 44px -30px rgba(9, 16, 32, 0.8);
}
/* 代码块顶部语言切换 */
.wb-console main [class*="color-code-bg"] [role="tablist"] [role="tab"] {
  color: rgba(255, 255, 255, 0.62) !important;
}
.wb-console main [class*="color-code-bg"] [role="tablist"] [role="tab"][aria-selected="true"] {
  background: rgba(255, 255, 255, 0.12) !important;
  color: #fff !important;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14) !important;
  backdrop-filter: blur(6px);
}

/* ---------------------------------------------------------------- 按钮 */
/* 主按钮：品牌蓝渐变 + 投影，替掉原来的纯色块 */
.wb-console main button[class*="bg-primary"],
.wb-console main a[class*="bg-primary"],
.wb-console .workspace-header-shell a[class*="bg-primary"],
.wb-console .workspace-header-shell button[class*="bg-primary"] {
  background: linear-gradient(180deg, #1b87ff 0%, #0071e3 100%) !important;
  color: #fff !important;
  font-weight: 600 !important;
  border-radius: 999px !important;
  box-shadow: 0 1px 1px rgba(16, 24, 40, 0.06), 0 8px 18px -8px rgba(0, 113, 227, 0.62),
    inset 0 1px 0 rgba(255, 255, 255, 0.26) !important;
  transition: transform 0.16s ease, box-shadow 0.16s ease, filter 0.16s ease;
}
.wb-console main button[class*="bg-primary"]:hover,
.wb-console main a[class*="bg-primary"]:hover {
  filter: brightness(1.04);
  box-shadow: 0 1px 1px rgba(16, 24, 40, 0.06), 0 12px 22px -8px rgba(0, 113, 227, 0.7),
    inset 0 1px 0 rgba(255, 255, 255, 0.3) !important;
}
.wb-console main button[class*="bg-primary"]:active,
.wb-console main a[class*="bg-primary"]:active {
  transform: translateY(1px);
}

/* 次按钮：白底描边 + 轻投影 */
.wb-console main a[class*="rounded-[var(--radius-control)]"][class*="border-border"],
.wb-console main button[class*="rounded-[var(--radius-control)]"][class*="border-border"] {
  background: #fff !important;
  border-color: var(--wb-line) !important;
  color: var(--wb-ink-2) !important;
  font-weight: 500;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}
.wb-console main a[class*="rounded-[var(--radius-control)]"][class*="border-border"]:hover {
  border-color: rgba(0, 113, 227, 0.35) !important;
  color: var(--color-sidebar-accent-foreground) !important;
  background: #f7faff !important;
  box-shadow: 0 2px 8px -4px rgba(0, 113, 227, 0.4);
}

/* ---------------------------------------------------------------- 表格 */
.wb-console main table thead th {
  background: #f8fafd;
  color: #667085 !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  letter-spacing: 0.01em;
  border-bottom: 1px solid var(--wb-line) !important;
  padding-top: 10px !important;
  padding-bottom: 10px !important;
  white-space: nowrap;
}
.wb-console main table tbody tr {
  transition: background-color 0.12s ease;
}
.wb-console main table tbody tr:hover {
  background: #f8fafd;
}
.wb-console main table tbody td {
  border-bottom: 1px solid var(--wb-line-soft) !important;
}

/* ---------------------------------------------------------------- 表单 */
.wb-console main input[type="text"],
.wb-console main input[type="search"],
.wb-console main input:not([type]),
.wb-console main select {
  border-radius: 10px !important;
  border-color: var(--wb-line) !important;
  background: #fff !important;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.03);
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}
.wb-console main input:focus,
.wb-console main select:focus,
.wb-console main textarea:focus {
  border-color: rgba(0, 113, 227, 0.55) !important;
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.12) !important;
  outline: none !important;
}

/* ---------------------------------------------------------- 空状态容器 */
.wb-console main [class*="place-items-center"] > svg {
  opacity: 0.9;
}

/* -------------------------------------------------------------- 滚动条 */
.wb-console ::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
.wb-console ::-webkit-scrollbar-thumb {
  background: rgba(16, 24, 40, 0.16);
  border-radius: 999px;
  border: 3px solid transparent;
  background-clip: content-box;
}
.wb-console ::-webkit-scrollbar-thumb:hover {
  background: rgba(16, 24, 40, 0.28);
  background-clip: content-box;
}
.wb-console ::-webkit-scrollbar-track {
  background: transparent;
}

/* ------------------------------------------------------------ 响应式兜底 */
@media (max-width: 1024px) {
  .wb-console main.api-platform-stage > div {
    max-width: none;
  }
  .wb-console .pb-6:has([data-testid="console-greeting"]) {
    padding: 18px !important;
  }
}

/* ------------------------------------------- 顶部维护公告不再压住控制台顶栏 */
/* --wb-notice-h 由 server.js 注入的脚本按公告实际高度写入（没有公告时为 0px） */
.wb-console body > div[class*="h-dvh"] {
  height: calc(100dvh - var(--wb-notice-h, 0px)) !important;
  margin-top: var(--wb-notice-h, 0px);
  transition: margin-top 0.16s ease, height 0.16s ease;
}
