/* ==========================================================================
 * 数智训练台 · 设计系统
 * 浅色渐变背景 + 半透明毛玻璃卡片 + 蓝紫渐层主色
 * ========================================================================== */

:root {
  --brand: #4b6ef5;
  --brand-2: #7a63f6;
  --brand-3: #56b8ff;
  --grad: linear-gradient(135deg, #4b6ef5 0%, #7466f6 55%, #9a63f0 100%);
  --grad-soft: linear-gradient(135deg, rgba(75, 110, 245, .12), rgba(154, 99, 240, .12));

  --ink: #17203a;
  --ink-2: #404c6b;
  --ink-3: #7c89a8;
  --ink-4: #a3aec7;

  --green: #1fbe89;
  --orange: #f6a13c;
  --cyan: #24c1e0;
  --pink: #f2699b;
  --red: #f0554c;
  --violet: #9b6ef3;
  --yellow: #f3c33f;

  --card: rgba(255, 255, 255, .84);
  --card-solid: #fff;
  --line: rgba(28, 45, 96, .07);
  --line-2: rgba(28, 45, 96, .12);

  --r-lg: 20px;
  --r-md: 14px;
  --r-sm: 10px;
  --shadow: 0 12px 34px -16px rgba(43, 62, 133, .22), 0 2px 6px -2px rgba(43, 62, 133, .06);
  --shadow-sm: 0 6px 18px -12px rgba(43, 62, 133, .3);

  --sidebar-w: 212px;
  --font: "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Code", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

/* 图标兜底尺寸：避免内联 SVG 退化为 300x150 撑坏布局 */
svg { width: 16px; height: 16px; flex: 0 0 auto; }
.statusbar svg, .tiny svg, .step svg, .lrow svg { width: 13px; height: 13px; }
.card-head svg, .more svg { width: 12px; height: 12px; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  font-size: 13px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(760px 520px at 4% -6%, #d9e3ff 0%, rgba(217, 227, 255, 0) 62%),
    radial-gradient(680px 520px at 32% 4%, #e8e2ff 0%, rgba(232, 226, 255, 0) 60%),
    radial-gradient(720px 460px at 72% -8%, #f3dcff 0%, rgba(243, 220, 255, 0) 58%),
    radial-gradient(900px 620px at 96% 12%, #dfeaff 0%, rgba(223, 234, 255, 0) 60%),
    radial-gradient(820px 700px at 60% 108%, #dcf0ff 0%, rgba(220, 240, 255, 0) 62%),
    linear-gradient(148deg, #f2f5fe 0%, #f7f3ff 46%, #eef6ff 100%);
  background-attachment: fixed;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(96, 115, 165, .22); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: rgba(96, 115, 165, .38); }
::-webkit-scrollbar-track { background: transparent; }

/* ------------------------------ 布局 ------------------------------ */
.app {
  display: flex;
  gap: 16px;
  height: 100vh;
  padding: 16px;
  overflow: hidden;
}

/* ------------------------------ 侧边栏 ------------------------------ */
.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, .74);
  backdrop-filter: blur(22px) saturate(160%);
  border: 1px solid rgba(255, 255, 255, .9);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding: 16px 12px 12px;
  overflow: hidden;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 2px 6px 16px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 12px;
  background: var(--grad);
  display: grid; place-items: center;
  box-shadow: 0 8px 18px -8px rgba(75, 110, 245, .8);
  flex: 0 0 auto;
}
.brand-mark svg { width: 20px; height: 20px; fill: none; stroke: #fff; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.brand-name { font-size: 15px; font-weight: 800; letter-spacing: .01em; line-height: 1.2; }
.brand-sub { font-size: 10.5px; color: var(--ink-3); letter-spacing: .06em; margin-top: 1px; }

.nav { flex: 1; overflow-y: auto; margin: 0 -4px; padding: 0 4px; }
.nav-group-label {
  font-size: 10.5px; color: var(--ink-4); letter-spacing: .1em;
  padding: 12px 10px 6px; font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  height: 40px; padding: 0 11px; margin-bottom: 3px;
  border-radius: 11px; color: var(--ink-2); font-size: 13px; font-weight: 500;
  cursor: pointer; user-select: none; position: relative;
  transition: background .18s, color .18s, transform .18s;
}
.nav-item svg { width: 17px; height: 17px; flex: 0 0 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; opacity: .82; }
.nav-item:hover { background: rgba(75, 110, 245, .075); color: var(--brand); }
.nav-item.active {
  background: var(--grad); color: #fff; font-weight: 600;
  box-shadow: 0 10px 22px -12px rgba(75, 110, 245, .95);
}
.nav-item.active svg { opacity: 1; }
.nav-item .dot { margin-left: auto; width: 6px; height: 6px; border-radius: 50%; background: var(--orange); box-shadow: 0 0 0 3px rgba(246, 161, 60, .18); }
.nav-item.active .dot { background: #fff; box-shadow: none; }

.side-status {
  margin-top: 10px; padding: 11px 12px;
  border-radius: 14px; background: rgba(255, 255, 255, .8);
  border: 1px solid var(--line); box-shadow: var(--shadow-sm);
}
.side-status .row { display: flex; align-items: center; gap: 7px; }
.side-status .pulse {
  width: 8px; height: 8px; border-radius: 50%; background: var(--green);
  box-shadow: 0 0 0 4px rgba(31, 190, 137, .16); animation: pulse 2.4s infinite;
}
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 3px rgba(31, 190, 137, .18); } 50% { box-shadow: 0 0 0 7px rgba(31, 190, 137, .04); } }
.side-status .t { font-size: 11.5px; color: var(--ink-3); }
.side-status .v { font-size: 12.5px; font-weight: 700; color: var(--green); }
.side-status .meta { font-size: 10.5px; color: var(--ink-4); margin-top: 4px; display: flex; justify-content: space-between; }

/* ------------------------------ 主区 ------------------------------ */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 14px; overflow: hidden; }

.topbar { display: flex; align-items: flex-start; gap: 16px; padding: 2px 4px 0; flex: 0 0 auto; }
.topbar h1 { font-size: 21px; font-weight: 800; margin: 0; letter-spacing: -.01em; line-height: 1.25; }
.topbar .sub { font-size: 11.5px; color: var(--ink-3); margin-top: 3px; letter-spacing: .02em; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 9px; }

.chip {
  display: inline-flex; align-items: center; gap: 7px;
  height: 34px; padding: 0 13px; border-radius: 11px;
  background: rgba(255, 255, 255, .72); border: 1px solid rgba(255, 255, 255, .9);
  box-shadow: var(--shadow-sm); font-size: 12px; color: var(--ink-2); font-weight: 500;
  backdrop-filter: blur(12px);
}
.chip svg { width: 15px; height: 15px; fill: none; stroke: var(--brand); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.chip.user { padding-right: 6px; }
.avatar {
  width: 26px; height: 26px; border-radius: 9px; background: var(--grad);
  color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center;
}

.icon-btn {
  width: 34px; height: 34px; border-radius: 11px; border: 1px solid rgba(255, 255, 255, .9);
  background: rgba(255, 255, 255, .72); box-shadow: var(--shadow-sm);
  display: grid; place-items: center; cursor: pointer; color: var(--ink-2);
  transition: .18s;
}
.icon-btn:hover { color: var(--brand); transform: translateY(-1px); }
.icon-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.view { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 0 4px 8px; }
.view::-webkit-scrollbar { width: 6px; }

/* ------------------------------ 卡片 ------------------------------ */
.card {
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, .92);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px) saturate(150%);
  padding: 14px 16px 12px;
  position: relative;
  overflow: hidden;
  display: flex; flex-direction: column;
  min-width: 0;
}
.card.pad0 { padding: 0; }
.card-head { display: flex; align-items: center; gap: 9px; margin-bottom: 8px; flex: 0 0 auto; }
.card-head .t { font-size: 13.5px; font-weight: 700; letter-spacing: .01em; white-space: nowrap; }
.card-head .s { font-size: 10.5px; color: var(--ink-4); font-weight: 400; margin-left: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.card-head .more {
  margin-left: auto; font-size: 11px; color: var(--ink-3); cursor: pointer; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 3px; transition: color .18s; flex: 0 0 auto;
}
.card-head .more:hover { color: var(--brand); }
.card-body { flex: 1; min-height: 0; }

.mark {
  width: 3px; height: 13px; border-radius: 3px; background: var(--grad); flex: 0 0 3px;
}
.tag-soft {
  font-size: 10px; padding: 2px 7px; border-radius: 6px; white-space: nowrap;
  background: rgba(75, 110, 245, .09); color: var(--brand); font-weight: 600;
}
.tag-soft.green { background: rgba(31, 190, 137, .11); color: var(--green); }
.tag-soft.orange { background: rgba(246, 161, 60, .13); color: #d98a24; }
.tag-soft.red { background: rgba(240, 85, 76, .11); color: var(--red); }
.tag-soft.grey { background: rgba(124, 137, 168, .12); color: var(--ink-3); }

/* ------------------------------ 网格 ------------------------------ */
.grid { display: grid; gap: 14px; }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.g-1-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
.g-3-2 { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
.stack { display: flex; flex-direction: column; gap: 14px; }

/* ------------------------------ KPI ------------------------------ */
.kpi {
  display: flex; flex-direction: column; gap: 2px;
  padding: 13px 15px 12px; border-radius: var(--r-md);
  background: var(--card); border: 1px solid rgba(255, 255, 255, .92);
  box-shadow: var(--shadow); backdrop-filter: blur(18px);
  position: relative; overflow: hidden;
}
.kpi::after {
  content: ""; position: absolute; right: -34px; top: -46px; width: 104px; height: 104px;
  border-radius: 50%; background: var(--tint, rgba(75, 110, 245, .1)); filter: blur(16px); opacity: .9;
}
.kpi-top { display: flex; align-items: center; gap: 9px; position: relative; z-index: 1; }
.kpi-ico {
  width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center;
  background: var(--tint, rgba(75, 110, 245, .12)); color: var(--accent, var(--brand));
}
.kpi-ico svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.kpi-label { font-size: 11.5px; color: var(--ink-3); font-weight: 500; }
.kpi-val { font-size: 25px; font-weight: 800; letter-spacing: -.02em; line-height: 1.25; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi-val .unit { font-size: 11.5px; font-weight: 600; color: var(--ink-3); margin-left: 3px; }
.kpi-delta { font-size: 10.5px; color: var(--ink-4); margin-top: 1px; display: flex; align-items: center; gap: 4px; }
.kpi-delta b { color: var(--green); font-weight: 700; }
.kpi-delta.down b { color: var(--red); }

/* ------------------------------ 图表容器 ------------------------------ */
.chart { width: 100%; height: 240px; }
.chart.tall { height: 300px; }
.chart.short { height: 190px; }
.chart.xs { height: 150px; }

/* ------------------------------ 表格 ------------------------------ */
.tbl-wrap { overflow: auto; border-radius: 12px; border: 1px solid var(--line); background: rgba(255, 255, 255, .6); }
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12px; }
.tbl th {
  position: sticky; top: 0; z-index: 2; text-align: left; font-weight: 600;
  color: var(--ink-3); background: #f6f8ff; padding: 8px 10px; white-space: nowrap;
  border-bottom: 1px solid var(--line); font-size: 11.5px; letter-spacing: .01em;
}
.tbl td { padding: 7px 10px; border-bottom: 1px solid rgba(28, 45, 96, .05); color: var(--ink-2); white-space: nowrap; }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover td { background: rgba(75, 110, 245, .04); }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .null { color: var(--ink-4); font-style: italic; }
.tbl.compact td { padding: 5px 9px; }

/* ------------------------------ 按钮 / 控件 ------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line-2);
  background: #fff; color: var(--ink-2); font-size: 12px; font-weight: 600;
  font-family: var(--font); cursor: pointer; transition: .18s; white-space: nowrap;
}
.btn:hover { border-color: rgba(75, 110, 245, .35); color: var(--brand); }
.btn svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn.primary { background: var(--grad); border-color: transparent; color: #fff; box-shadow: 0 10px 20px -12px rgba(75, 110, 245, .9); }
.btn.primary:hover { filter: brightness(1.04); transform: translateY(-1px); color: #fff; }
.btn.ghost { background: rgba(255, 255, 255, .6); }
.btn.sm { height: 27px; padding: 0 10px; font-size: 11.5px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.input, .select {
  height: 32px; padding: 0 11px; border-radius: 10px; border: 1px solid var(--line-2);
  background: #fff; font-size: 12px; color: var(--ink); font-family: var(--font); outline: none;
  transition: .18s; min-width: 0;
}
.input:focus, .select:focus { border-color: rgba(75, 110, 245, .55); box-shadow: 0 0 0 3px rgba(75, 110, 245, .1); }
.input::placeholder { color: var(--ink-4); }
.select { cursor: pointer; appearance: none; padding-right: 26px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237c89a8' stroke-width='2.4'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 9px center; }

.tabs { display: inline-flex; gap: 2px; padding: 3px; border-radius: 11px; background: rgba(28, 45, 96, .05); }
.tabs .tab {
  padding: 5px 13px; border-radius: 8px; font-size: 12px; color: var(--ink-3);
  cursor: pointer; font-weight: 500; transition: .18s; white-space: nowrap; border: none; background: none; font-family: var(--font);
}
.tabs .tab:hover { color: var(--brand); }
.tabs .tab.active { background: #fff; color: var(--brand); font-weight: 700; box-shadow: 0 4px 10px -6px rgba(43, 62, 133, .4); }
.tabs.sm .tab { padding: 3px 10px; font-size: 11.5px; }

.seg { display: flex; gap: 8px; flex-wrap: wrap; }

/* 进度条 */
.pbar { height: 7px; border-radius: 6px; background: rgba(28, 45, 96, .07); overflow: hidden; }
.pbar > i { display: block; height: 100%; border-radius: 6px; background: var(--grad); transition: width .6s cubic-bezier(.4, 0, .2, 1); }
.pbar.thin { height: 5px; }

/* 列表行 */
.lrow { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px dashed var(--line); }
.lrow:last-child { border-bottom: none; }
.lrow .lb { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.lrow .ls { font-size: 10.5px; color: var(--ink-4); }
.lrow .lv { margin-left: auto; font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }

.dotc { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 7px; background: var(--brand); }

/* ------------------------------ 代码编辑器 ------------------------------ */
.editor {
  position: relative; border-radius: 12px; overflow: hidden;
  border: 1px solid rgba(28, 45, 96, .1);
  background: linear-gradient(180deg, #fbfcff, #f6f8fe);
  font-family: var(--mono); font-size: 12.5px; line-height: 1.7;
  display: flex; flex-direction: column;
}
.editor-toolbar {
  display: flex; align-items: center; gap: 8px; padding: 7px 10px;
  background: rgba(255, 255, 255, .7); border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}
.editor-toolbar .lang { font-size: 10.5px; font-weight: 700; letter-spacing: .08em; color: var(--brand); background: rgba(75, 110, 245, .1); padding: 2px 7px; border-radius: 5px; font-family: var(--font); }
.editor-scroll { position: relative; flex: 1; min-height: 0; display: flex; }
.gutter {
  flex: 0 0 38px; padding: 10px 6px 10px 0; text-align: right; color: #b6c0d6;
  font-size: 11px; line-height: 1.7; user-select: none; background: rgba(246, 248, 254, .7);
  border-right: 1px solid var(--line); overflow: hidden;
}
.gutter span { display: block; height: 21.25px; }
.editor-code { position: relative; flex: 1; min-width: 0; }
.editor-code pre, .editor-code textarea {
  margin: 0; padding: 10px 12px; font-family: var(--mono); font-size: 12.5px; line-height: 1.7;
  white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere;
  border: 0; outline: none; background: transparent; tab-size: 2;
}
.editor-code pre { position: absolute; inset: 0; overflow: auto; pointer-events: none; color: #33405e; }
.editor-code textarea {
  position: relative; width: 100%; height: 100%; resize: none; color: transparent;
  caret-color: #2b3552; overflow: auto; display: block;
}
.editor-code textarea::selection { background: rgba(75, 110, 245, .2); }

.tok-kw { color: #7a4fe0; font-weight: 600; }
.tok-fn { color: #1f7fd6; }
.tok-str { color: #c8611e; }
.tok-num { color: #1f9d7a; }
.tok-com { color: #9aa5bd; font-style: italic; }
.tok-op { color: #6b7897; }
.tok-id { color: #33405e; }

.autocomplete {
  position: absolute; z-index: 40; min-width: 180px; max-height: 190px; overflow: auto;
  background: #fff; border: 1px solid var(--line-2); border-radius: 10px;
  box-shadow: 0 16px 34px -14px rgba(43, 62, 133, .4); padding: 4px; display: none;
  font-family: var(--font);
}
.autocomplete .ac-item { padding: 5px 9px; border-radius: 7px; font-size: 12px; cursor: pointer; display: flex; align-items: center; gap: 8px; color: var(--ink-2); }
.autocomplete .ac-item:hover, .autocomplete .ac-item.sel { background: rgba(75, 110, 245, .09); color: var(--brand); }
.autocomplete .ac-item .k { font-size: 9.5px; color: var(--ink-4); margin-left: auto; }

/* 结果状态条 */
.statusbar { display: flex; align-items: center; gap: 12px; font-size: 11px; color: var(--ink-3); padding: 7px 2px 0; }
.statusbar b { color: var(--ink-2); font-weight: 700; }
.statusbar .ok { color: var(--green); }
.statusbar .err { color: var(--red); }

/* ------------------------------ 图表库卡片 ------------------------------ */
.chart-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(178px, 1fr)); gap: 11px; }
.chart-card {
  background: rgba(255, 255, 255, .82); border: 1px solid rgba(255, 255, 255, .95);
  border-radius: 14px; padding: 9px 10px 8px; cursor: pointer;
  box-shadow: var(--shadow-sm); transition: .2s; position: relative; overflow: hidden;
}
.chart-card:hover { transform: translateY(-2px); box-shadow: 0 16px 30px -18px rgba(43, 62, 133, .5); border-color: rgba(75, 110, 245, .3); }
.chart-card .thumb { height: 74px; border-radius: 9px; background: linear-gradient(160deg, #f7f9ff, #eef3ff); overflow: hidden; position: relative; }
.chart-card .nm { font-size: 12px; font-weight: 600; margin-top: 7px; display: flex; align-items: center; gap: 5px; }
.chart-card .no { font-size: 9.5px; color: var(--brand); background: rgba(75, 110, 245, .1); padding: 0 5px; border-radius: 4px; font-weight: 700; }
.chart-card .ct { font-size: 10px; color: var(--ink-4); margin-top: 1px; }

/* 详情双栏 */
.detail { display: grid; grid-template-columns: minmax(0, 380px) minmax(0, 1fr); gap: 14px; height: 100%; }
.detail-left { display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.detail-right { display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.detail-right > .card:first-child { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; }
.detail-right > .card:first-child > .card-body { flex: 1 1 auto; min-height: 0; padding-bottom: 6px; }

.code-block {
  background: #1c2333; color: #cfd8ea; border-radius: 11px; padding: 11px 12px;
  font-family: var(--mono); font-size: 11.5px; line-height: 1.65; overflow: auto;
  white-space: pre; position: relative; max-height: 320px;
}
.code-block .tok-kw { color: #a78bfa; }
.code-block .tok-fn { color: #5eb3f6; }
.code-block .tok-str { color: #f5b270; }
.code-block .tok-num { color: #6ee7b7; }
.code-block .tok-com { color: #6b7794; }
.code-block .tok-id { color: #cfd8ea; }
.code-block .tok-op { color: #94a3bd; }

.copy-btn {
  position: absolute; right: 8px; top: 8px; font-size: 10.5px;
  background: rgba(255, 255, 255, .12); color: #dbe3f3; border: none;
  padding: 3px 8px; border-radius: 6px; cursor: pointer; font-family: var(--font);
}
.copy-btn:hover { background: rgba(255, 255, 255, .22); }

/* ------------------------------ 抽屉 / 弹层 ------------------------------ */
.drawer-mask {
  position: fixed; inset: 0; background: rgba(23, 32, 58, .22);
  backdrop-filter: blur(3px); z-index: 90; opacity: 0; pointer-events: none; transition: .25s;
}
.drawer-mask.on { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; right: 0; top: 0; bottom: 0; width: 460px; z-index: 91;
  background: linear-gradient(180deg, #fbfcff, #f4f7ff);
  box-shadow: -20px 0 60px -24px rgba(23, 32, 58, .4);
  transform: translateX(102%); transition: transform .3s cubic-bezier(.4, 0, .2, 1);
  display: flex; flex-direction: column; border-left: 1px solid rgba(255, 255, 255, .8);
}
.drawer.on { transform: none; }
.drawer-head { display: flex; align-items: center; gap: 10px; padding: 16px 18px 12px; border-bottom: 1px solid var(--line); }
.drawer-head .t { font-size: 14px; font-weight: 800; }
.drawer-body { flex: 1; overflow-y: auto; padding: 14px 18px 22px; }

.toast-wrap { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 120; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  padding: 9px 16px; border-radius: 11px; background: rgba(23, 32, 58, .92); color: #fff;
  font-size: 12px; box-shadow: 0 14px 30px -14px rgba(0, 0, 0, .5);
  animation: toastIn .3s cubic-bezier(.2, .9, .3, 1.2); display: flex; align-items: center; gap: 7px;
}
.toast.ok { background: linear-gradient(135deg, #17a97a, #1fbe89); }
.toast.err { background: linear-gradient(135deg, #d9453c, #f0554c); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px) scale(.96); } }

/* ------------------------------ 算法面板 ------------------------------ */
.steps { display: flex; flex-direction: column; gap: 0; }
.step {
  display: flex; gap: 11px; padding: 9px 0; position: relative;
}
.step:not(:last-child)::before {
  content: ""; position: absolute; left: 11px; top: 28px; bottom: -2px; width: 1.5px;
  background: linear-gradient(180deg, rgba(75, 110, 245, .35), rgba(75, 110, 245, .05));
}
.step .idx {
  width: 23px; height: 23px; border-radius: 8px; flex: 0 0 23px; z-index: 1;
  background: rgba(75, 110, 245, .1); color: var(--brand); font-size: 11px; font-weight: 700;
  display: grid; place-items: center; transition: .25s;
}
.step.on .idx { background: var(--grad); color: #fff; box-shadow: 0 6px 14px -8px rgba(75, 110, 245, .9); }
.step .st { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.step .sd { font-size: 10.5px; color: var(--ink-4); margin-top: 1px; }
.step .sv { margin-left: auto; font-size: 11px; color: var(--brand); font-weight: 700; }

/* 滑杆 */
input[type=range] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 4px; border-radius: 4px;
  background: rgba(28, 45, 96, .12); outline: none;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%;
  background: #fff; border: 3px solid var(--brand); cursor: pointer;
  box-shadow: 0 2px 6px rgba(43, 62, 133, .3);
}

/* ------------------------------ ETL 画布 ------------------------------ */
.etl-canvas {
  position: relative; height: 100%; min-height: 360px; border-radius: 14px;
  border: 1px dashed rgba(75, 110, 245, .25);
  background:
    radial-gradient(circle at 1px 1px, rgba(75, 110, 245, .14) 1px, transparent 0) 0 0 / 18px 18px,
    linear-gradient(180deg, #fbfcff, #f5f8ff);
  overflow: hidden;
}
.etl-node {
  position: absolute; width: 148px; padding: 9px 11px; border-radius: 12px;
  background: #fff; border: 1px solid var(--line-2); box-shadow: 0 10px 24px -16px rgba(43, 62, 133, .5);
  cursor: grab; user-select: none; transition: box-shadow .2s, border-color .2s;
}
.etl-node:active { cursor: grabbing; }
.etl-node.sel { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(75, 110, 245, .12), 0 10px 24px -16px rgba(43, 62, 133, .5); }
.etl-node .nh { display: flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 700; }
.etl-node .nd { font-size: 9.5px; color: var(--ink-4); margin-top: 2px; font-family: var(--mono); }
.etl-node .port { position: absolute; width: 9px; height: 9px; border-radius: 50%; background: #fff; border: 2px solid var(--brand); top: 50%; margin-top: -4.5px; }
.etl-node .port.in { left: -5px; }
.etl-node .port.out { right: -5px; cursor: crosshair; }
.etl-node.running { border-color: var(--orange); }
.etl-node.done { border-color: var(--green); }
.etl-node .badge { position: absolute; right: -6px; top: -7px; font-size: 9px; padding: 1px 6px; border-radius: 20px; background: var(--grad); color: #fff; font-weight: 700; }

.log-box {
  font-family: var(--mono); font-size: 11px; line-height: 1.75; background: #161d2c; color: #b9c6dd;
  border-radius: 11px; padding: 10px 12px; overflow: auto; height: 100%;
}
.log-box .lg-time { color: #64748b; }
.log-box .lg-ok { color: #4ade80; }
.log-box .lg-warn { color: #fbbf24; }
.log-box .lg-err { color: #f87171; }
.log-box .lg-info { color: #7dd3fc; }

/* ------------------------------ 通用 ------------------------------ */
.muted { color: var(--ink-3); }
.tiny { font-size: 10.5px; }
.mono { font-family: var(--mono); }
.flex { display: flex; align-items: center; gap: 8px; }
.flex-1 { flex: 1; min-width: 0; }
.wrap { flex-wrap: wrap; }
.mt6 { margin-top: 6px; } .mt10 { margin-top: 10px; } .mt14 { margin-top: 14px; }
.mb6 { margin-bottom: 6px; } .mb10 { margin-bottom: 10px; }
.center { text-align: center; }
.right { text-align: right; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scroll-y { overflow-y: auto; }
.big-num { font-size: 27px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }

.split-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.empty {
  display: grid; place-items: center; height: 100%; min-height: 120px;
  color: var(--ink-4); font-size: 12px; gap: 6px;
}
.empty svg { width: 30px; height: 30px; stroke: currentColor; fill: none; stroke-width: 1.4; opacity: .5; }

/* 骨架/加载 */
.loading { position: relative; }
.loading::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, .55), rgba(255, 255, 255, 0));
  animation: shimmer 1.1s infinite;
}
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

/* 段位卡 */
.rank-card {
  background: linear-gradient(135deg, #3f5ef0 0%, #6d5cf0 48%, #9a63f0 100%);
  color: #fff; border-radius: var(--r-md); padding: 14px 16px; position: relative; overflow: hidden;
  box-shadow: 0 18px 34px -20px rgba(75, 110, 245, .9);
}
.rank-card::after {
  content: ""; position: absolute; right: -34px; bottom: -50px; width: 150px; height: 150px;
  border-radius: 50%; background: rgba(255, 255, 255, .12);
}
.rank-card::before {
  content: ""; position: absolute; right: 24px; top: -60px; width: 110px; height: 110px;
  border-radius: 50%; background: rgba(255, 255, 255, .08);
}
.rank-title { font-size: 11px; opacity: .78; letter-spacing: .1em; }
.rank-name { font-size: 19px; font-weight: 800; margin-top: 3px; letter-spacing: .01em; }
.rank-xp { font-size: 10.5px; opacity: .86; margin-top: 2px; }
.rank-bar { height: 5px; border-radius: 5px; background: rgba(255, 255, 255, .24); margin-top: 9px; overflow: hidden; }
.rank-bar > i { display: block; height: 100%; background: #fff; border-radius: 5px; box-shadow: 0 0 10px rgba(255, 255, 255, .7); }
.rank-badges { display: flex; gap: 6px; margin-top: 10px; }
.rank-badges span { font-size: 9.5px; padding: 2px 7px; border-radius: 20px; background: rgba(255, 255, 255, .18); }

/* 流程条 */
.flow { display: flex; align-items: center; gap: 0; padding: 4px 0 2px; }
.flow-node { flex: 1; text-align: center; position: relative; }
.flow-node .fi {
  width: 34px; height: 34px; border-radius: 11px; margin: 0 auto 6px; display: grid; place-items: center;
  background: linear-gradient(160deg, #eef2ff, #e6ecff); color: var(--brand); border: 1px solid rgba(75, 110, 245, .14);
}
.flow-node.done .fi { background: var(--grad); color: #fff; border-color: transparent; box-shadow: 0 8px 16px -10px rgba(75, 110, 245, .9); }
.flow-node .fi svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.flow-node .fn { font-size: 11px; font-weight: 600; color: var(--ink-2); }
.flow-node .fs { font-size: 9.5px; color: var(--ink-4); }
.flow-arrow { flex: 0 0 24px; height: 1px; background: linear-gradient(90deg, rgba(75, 110, 245, .35), rgba(75, 110, 245, .12)); position: relative; margin-bottom: 22px; }
.flow-arrow::after {
  content: ""; position: absolute; right: 0; top: -2.5px; border-left: 5px solid rgba(75, 110, 245, .4);
  border-top: 3px solid transparent; border-bottom: 3px solid transparent;
}

@media (max-width: 1400px) {
  .g-5 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .detail { grid-template-columns: minmax(0, 330px) minmax(0, 1fr); }
}

/* ==========================================================================
 * 登录态遮罩 + 顶栏用户菜单
 * ========================================================================== */
#auth-mask {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: none;
  place-items: center;
  background: rgba(244, 247, 255, .72);
  backdrop-filter: blur(6px);
}
body.auth-pending #auth-mask { display: grid; }
body.auth-pending .toast-wrap { display: none; }
.am-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 22px;
  background: rgba(255, 255, 255, .92);
  border: 1px solid rgba(255, 255, 255, .9);
  border-radius: 14px;
  box-shadow: 0 20px 44px -24px rgba(43, 62, 133, .5);
  font-size: 12.5px;
  color: var(--ink-2);
}
.am-spin {
  width: 16px; height: 16px;
  border: 2px solid rgba(75, 110, 245, .22);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: amrot .7s linear infinite;
}
@keyframes amrot { to { transform: rotate(360deg); } }

.user-wrap { position: relative; }
.chip.user { cursor: pointer; user-select: none; transition: box-shadow .16s, background .16s; }
.chip.user:hover, .chip.user.active { box-shadow: 0 6px 16px -10px rgba(43, 62, 133, .5); background: #fff; }

.user-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 208px;
  padding: 8px;
  background: #fff;
  border: 1px solid rgba(255, 255, 255, .9);
  border-radius: 14px;
  box-shadow: 0 24px 48px -26px rgba(43, 62, 133, .55), 0 2px 8px -4px rgba(43, 62, 133, .12);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px) scale(.985);
  transform-origin: top right;
  transition: opacity .16s, transform .16s, visibility .16s;
  z-index: 60;
}
.user-menu.open { opacity: 1; visibility: visible; transform: none; }
.um-head { display: flex; align-items: center; gap: 9px; padding: 4px 6px 9px; }
.um-av {
  width: 34px; height: 34px;
  border-radius: 11px;
  background: var(--grad);
  color: #fff;
  display: grid; place-items: center;
  font-size: 14px; font-weight: 700;
  flex: 0 0 auto;
}
.um-name { font-size: 12.5px; font-weight: 700; color: var(--ink); line-height: 1.5; }
.um-acc { font-size: 10.5px; color: var(--ink-4); font-family: var(--mono); line-height: 1.5; }
.um-role {
  font-size: 10.5px;
  color: var(--brand);
  background: rgba(75, 110, 245, .08);
  border-radius: 7px;
  padding: 4px 8px;
  margin: 0 6px 7px;
  display: inline-block;
  white-space: nowrap;
}
.um-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: transparent;
  font-family: inherit;
  font-size: 11.5px;
  color: var(--ink-2);
  padding: 8px 9px;
  border-radius: 9px;
  cursor: pointer;
  text-align: left;
  transition: background .14s, color .14s;
}
.um-item:hover { background: rgba(75, 110, 245, .07); color: var(--brand); }
.um-item.danger:hover { background: rgba(240, 85, 76, .08); color: var(--red); }
.um-item svg { width: 14px; height: 14px; opacity: .8; }

/* ==========================================================================
 * 响应式：平板 / 手机
 * ========================================================================== */
.side-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  flex: 0 0 auto;
  margin-top: 1px;
  border: 1px solid rgba(255, 255, 255, .9);
  background: var(--card);
  border-radius: 10px;
  color: var(--ink-2);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.side-toggle svg { width: 17px; height: 17px; }

.nav-mask {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(23, 32, 58, .38);
  backdrop-filter: blur(3px);
  opacity: 0;
  visibility: hidden;
  transition: opacity .22s, visibility .22s;
}

@media (max-width: 1080px) {
  .app { padding: 10px; gap: 10px; }

  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: 238px;
    z-index: 80;
    border-radius: 0 20px 20px 0;
    background: rgba(255, 255, 255, .97);
    backdrop-filter: blur(18px);
    transform: translateX(-103%);
    transition: transform .26s cubic-bezier(.22, .8, .3, 1);
    box-shadow: 0 24px 60px -24px rgba(35, 50, 110, .5);
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .nav-mask { opacity: 1; visibility: visible; }

  .side-toggle { display: inline-flex; }

  .detail { grid-template-columns: minmax(0, 1fr); height: auto; }
  .detail-left { order: 2; }
  .detail-right { order: 1; }
  .detail-right .chart-box { height: 320px; }
  .detail-right > .card:first-child { flex: 0 0 auto; }
  .detail-right > .card:first-child > .card-body > div { height: 320px !important; min-height: 0; }
  .g-5, .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-3-2, .g-2-1, .g-1-2, .g-3 { grid-template-columns: minmax(0, 1fr); }
  .chart-grid { grid-template-columns: repeat(auto-fill, minmax(146px, 1fr)); }
}

@media (max-width: 760px) {
  body { font-size: 12.5px; }
  .app { padding: 8px; gap: 10px; }
  .topbar { gap: 10px; align-items: center; }
  .topbar h1 { font-size: 17px; }
  .topbar .sub { font-size: 10.5px; }
  .topbar-right { gap: 6px; flex-wrap: nowrap; }
  .topbar-right .chip { font-size: 11px; padding: 5px 9px; }
  .topbar-right #topbar-time { display: none; }
  .chip.user span { display: none; }
  .chip.user { padding: 5px 7px; }

  .g-5, .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-3, .g-2, .split-2 { grid-template-columns: minmax(0, 1fr); }
  .kpi-val { font-size: 21px; }
  .card { border-radius: 16px; }
  .card-body { padding: 12px; }
  .chart-box { height: 240px; }
  .detail-right .chart-box { height: 260px; }

  .table-scroll { overflow-x: auto; }
  .table-scroll table { min-width: 560px; }

  .editor, .code-block, pre { font-size: 11.5px; }
  .log-box { max-height: 220px; }
  .etl-canvas { min-height: 320px; overflow-x: auto; }
  .drawer { width: 100%; }
  .user-menu { width: 190px; }
}

@media (max-width: 420px) {
  .chart-grid { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); }
  .topbar .sub { display: none; }
}
