/* ==========================================================================
   Chervon EPM 数据平台 —— 设计系统 v4.0「Horizon」
   设计语言：参考 Linear / Vercel / Stripe —— 顶栏导航、中性灰阶、
   1px 细边框、克制的阴影、靛蓝强调色、等宽数字、深浅双主题。
   原则：简洁 > 装饰；层级靠间距与字重；动效 120-200ms。
   ========================================================================== */

:root, html[data-theme="light"] {
  --bg: #f6f7f9;
  --bg-panel: #ffffff;
  --bg-sub: #f2f3f7;
  --bg-hover: #eceef3;
  --border: #e5e7ee;
  --border-soft: #eef0f4;
  --ink: #16181f;
  --text: #23262f;
  --text-mid: #5b6070;
  --text-dim: #8d92a3;
  --primary: #4f5df7;
  --primary-hover: #3f4ef0;
  --primary-soft: #eef0ff;
  --primary-ring: rgba(79, 93, 247, .18);
  --ok: #16a34a;   --ok-soft: #e9f7ee;
  --warn: #b45309; --warn-soft: #fdf3e1;
  --info: #2563eb; --info-soft: #eaf1ff;
  --thead: #f7f8fb;
  --shadow-1: 0 1px 2px rgba(16,18,31,.04);
  --shadow-2: 0 4px 16px rgba(16,18,31,.06);
  --shadow-3: 0 16px 44px rgba(16,18,31,.14);
  --topbar-bg: rgba(255,255,255,.86);
  --scroll-thumb: #cfd3de;
}
html[data-theme="dark"] {
  --bg: #0c0d11;
  --bg-panel: #14161d;
  --bg-sub: #1a1d26;
  --bg-hover: #22252f;
  --border: #262a36;
  --border-soft: #1f222c;
  --ink: #eceef4;
  --text: #d6d9e2;
  --text-mid: #9ba0b0;
  --text-dim: #676d80;
  --primary: #7c8aff;
  --primary-hover: #8f9bff;
  --primary-soft: rgba(124,138,255,.14);
  --primary-ring: rgba(124,138,255,.25);
  --ok: #34c77b;   --ok-soft: rgba(52,199,123,.14);
  --warn: #e8a33d; --warn-soft: rgba(232,163,61,.14);
  --info: #5b9dff; --info-soft: rgba(91,157,255,.14);
  --thead: #1a1d26;
  --shadow-1: 0 1px 2px rgba(0,0,0,.4);
  --shadow-2: 0 4px 18px rgba(0,0,0,.45);
  --shadow-3: 0 18px 50px rgba(0,0,0,.6);
  --topbar-bg: rgba(15,16,22,.82);
  --scroll-thumb: #333748;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 13.5px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--primary-soft); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; border-radius: 6px; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border-radius: 99px; border: 3px solid transparent; background-clip: padding-box; }

/* ====== 顶栏 ====== */
.topbar {
  position: sticky; top: 0; z-index: 80;
  display: flex; align-items: center; gap: 18px;
  height: 52px; padding: 0 18px;
  background: var(--topbar-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar-brand { display: flex; align-items: center; gap: 9px; flex: none; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 7px;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  color: #fff; font-weight: 800; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
}
.brand-name { font-size: 14px; font-weight: 700; color: var(--ink); white-space: nowrap; }
.brand-name em { font-style: normal; color: var(--text-mid); font-weight: 600; margin-left: 2px; }

.tab-btn {
  appearance: none; border: none; background: transparent; cursor: pointer;
  font-family: inherit; font-size: 13px; font-weight: 500; color: var(--text-mid);
  padding: 6px 11px; border-radius: 8px; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px;
  transition: color .14s, background .14s;
}
.tab-btn:hover { color: var(--text); background: var(--bg-hover); }
.tab-btn.active { color: var(--primary); background: var(--primary-soft); font-weight: 650; }
.tab-btn .cnt {
  font-size: 10.5px; font-weight: 600; color: var(--text-dim);
  background: var(--bg-hover); border-radius: 99px; padding: 0 6px; line-height: 16px;
  font-variant-numeric: tabular-nums;
}
.tab-btn.active .cnt { color: var(--primary); background: transparent; }

.topbar-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.topbar-spacer { flex: 1; min-width: 0; }
/* 窄屏才出现：必须比 .icon-btn 更具体，否则被后者的 display 覆盖 */
.icon-btn.nav-toggle { display: none; }
.icon-btn {
  width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg-panel); color: var(--text-mid); cursor: pointer; font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all .14s;
}
.icon-btn:hover { color: var(--text); border-color: var(--text-dim); }

/* 环境下拉 */
.env-pop-wrap { position: relative; }
.env-pill {
  display: inline-flex; align-items: center; gap: 7px;
  height: 30px; padding: 0 11px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg-panel);
  color: var(--text); font-family: inherit; font-size: 12.5px; font-weight: 600;
  cursor: pointer; transition: border-color .14s;
}
.env-pill:hover { border-color: var(--text-dim); }
.env-pill-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.env-pill .caret {
  width: 5px; height: 5px; border-right: 1.5px solid var(--text-dim);
  border-bottom: 1.5px solid var(--text-dim); transform: rotate(45deg) translateY(-1px);
}
.env-pop {
  display: none; position: absolute; top: calc(100% + 6px); right: 0; z-index: 90;
  width: 240px; background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow-3); padding: 6px;
}
.env-pop.open { display: block; animation: pop .14s ease-out; }
.env-pop .env-btn {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 9px 11px; border-radius: 8px; border: none; background: transparent;
  cursor: pointer; font-family: inherit; text-align: left; transition: background .12s;
}
.env-pop .env-btn:hover { background: var(--bg-hover); }
.env-pop .env-btn .env-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-dim); flex: none; }
.env-pop .env-btn .env-dot.on { background: var(--ok); }
.env-pop .env-btn .env-name { font-size: 13px; font-weight: 600; color: var(--text); flex: 1; }
.env-pop .env-btn .env-sub { font-size: 11px; color: var(--text-dim); }
.env-pop .env-btn.active { background: var(--primary-soft); }
.env-pop .env-btn.active .env-name { color: var(--primary); }
.env-note { padding: 7px 11px 4px; font-size: 10.5px; color: var(--text-dim); border-top: 1px solid var(--border-soft); margin-top: 5px; }

/* 连接状态 pill */
.conn-pill {
  height: 30px; padding: 0 11px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); background: var(--bg-panel);
  font-family: inherit; font-size: 12.5px; font-weight: 550; color: var(--text-mid);
  display: inline-flex; align-items: center; gap: 7px; transition: border-color .14s, color .14s;
  max-width: 240px; overflow: hidden;
}
.conn-pill:hover { border-color: var(--text-dim); color: var(--text); }
.conn-pill .on { color: var(--ok); font-weight: 650; }

/* 更多菜单 */
.menu-wrap { position: relative; }
.dropdown {
  display: none; position: absolute; top: calc(100% + 6px); right: 0; z-index: 90;
  width: 220px; background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow-3); padding: 5px;
}
.dropdown.open { display: block; animation: pop .14s ease-out; }
.menu-item {
  display: block; width: 100%; text-align: left; padding: 9px 11px;
  border: none; background: transparent; border-radius: 8px; cursor: pointer;
  font-family: inherit; font-size: 13px; color: var(--text); transition: background .12s;
}
.menu-item:hover { background: var(--bg-hover); }
.menu-sep { border-top: 1px solid var(--border-soft); margin: 5px 6px; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* ====== 主体骨架：左侧功能树 + 主工作区 ====== */
.shell { display: flex; align-items: flex-start; }

.sidenav {
  flex: none; width: 238px;
  position: sticky; top: 52px;
  max-height: calc(100vh - 52px);
  overflow-y: auto; overscroll-behavior: contain;
  padding: 16px 12px 30px 18px;
  border-right: 1px solid var(--border);
}
.sidenav-head {
  font-size: 10.5px; font-weight: 700; letter-spacing: .09em;
  color: var(--text-dim); text-transform: uppercase;
  padding: 0 8px 9px;
}

.nav-tree { display: flex; flex-direction: column; gap: 3px; }
.nav-group { display: flex; flex-direction: column; }

.nav-group-head {
  appearance: none; border: none; background: transparent; cursor: pointer;
  font-family: inherit; width: 100%; text-align: left;
  display: flex; align-items: center; gap: 7px;
  padding: 7px 8px; border-radius: 8px;
  color: var(--text-mid); font-size: 12px; font-weight: 650; letter-spacing: .01em;
  transition: color .14s, background .14s;
}
.nav-group-head:hover { color: var(--text); background: var(--bg-hover); }
.nav-caret {
  flex: none; width: 0; height: 0;
  border-left: 4.5px solid currentColor;
  border-top: 3.5px solid transparent;
  border-bottom: 3.5px solid transparent;
  transition: transform .16s ease;
}
.nav-group.open .nav-caret { transform: rotate(90deg); }
.nav-glabel { flex: none; }
.nav-ghint {
  margin-left: auto; font-size: 9.5px; font-weight: 600;
  letter-spacing: .04em; color: var(--text-dim);
  text-transform: uppercase; opacity: .75;
}

/* 子级：缩进 + 层级参考线（树形观感） */
.nav-children {
  display: flex; flex-direction: column; gap: 1px;
  margin: 3px 0 7px 13px; padding-left: 10px;
  border-left: 1px solid var(--border);
}
.nav-group:not(.open) .nav-children { display: none; }

/* 组内小标题（不可点，仅做视觉分组） */
.nav-subhead {
  font-size: 10px; font-weight: 700; letter-spacing: .07em;
  color: var(--text-dim); text-transform: uppercase;
  padding: 9px 9px 3px; opacity: .8;
}

.nav-leaf {
  appearance: none; border: none; cursor: pointer; font-family: inherit;
  width: 100%; text-align: left;
  display: flex; align-items: center; gap: 8px;
  padding: 6px 9px; border-radius: 7px;
  background: transparent; color: var(--text-mid);
  font-size: 13px; font-weight: 500; line-height: 1.35;
  transition: color .14s, background .14s;
}
.nav-leaf:hover { color: var(--text); background: var(--bg-hover); }
.nav-leaf.active { color: var(--primary); background: var(--primary-soft); font-weight: 650; }
.nav-bullet {
  flex: none; width: 5px; height: 5px; border-radius: 99px;
  background: var(--text-dim); opacity: .5;
}
.nav-leaf:hover .nav-bullet { opacity: .9; }
.nav-leaf.active .nav-bullet { background: var(--primary); opacity: 1; }
.nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-act { color: var(--text-mid); }

/* 复用 .tab-btn 的计数样式（结构上是 .tab-btn.nav-leaf） */
.nav-tree .tab-btn.nav-leaf { display: flex; }
.nav-tree .tab-btn.nav-leaf .cnt { flex: none; }

/* ====== 主工作区 ====== */
.workspace { flex: 1; min-width: 0; padding: 20px 26px 60px; }
.info-line { font-size: 12px; color: var(--text-dim); margin-bottom: 14px; display: flex; gap: 14px; flex-wrap: wrap; }
.info-line b { color: var(--text-mid); font-weight: 600; font-variant-numeric: tabular-nums; }

.stat-strip {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px; margin-bottom: 18px;
}
.stat {
  appearance: none; cursor: pointer; text-align: left; font-family: inherit;
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 13px 15px; box-shadow: var(--shadow-1);
  display: flex; flex-direction: column; gap: 3px;
  transition: box-shadow .16s, transform .12s, border-color .16s;
}
.stat:hover { transform: translateY(-1px); box-shadow: var(--shadow-2); border-color: var(--text-dim); }
.stat-label { font-size: 11px; font-weight: 600; color: var(--text-dim); letter-spacing: .04em; }
.stat-value { font-size: 22px; font-weight: 750; color: var(--ink); line-height: 1.15; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.stat-unit { font-size: 11px; color: var(--text-dim); }

.panels { min-width: 0; }
.panel { display: none; }
.panel.active { display: block; animation: fade .18s ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

/* ====== 控件 ====== */
.btn {
  appearance: none; cursor: pointer; font-family: inherit; font-size: 13px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--bg-panel);
  color: var(--text); padding: 7px 13px; font-weight: 550;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: all .14s; white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: var(--text-dim); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.block { width: 100%; }
.btn.primary {
  background: var(--primary); border-color: var(--primary); color: #fff;
  box-shadow: 0 1px 2px rgba(79,93,247,.35);
}
.btn.primary:hover:not(:disabled) { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-ghost {
  padding: 5px 11px; background: transparent; border: 1px solid transparent;
  border-radius: 7px; font-size: 12.5px; color: var(--text-mid);
  font-family: inherit; cursor: pointer; transition: all .14s;
}
.btn-ghost:hover:not(:disabled) { color: var(--text); background: var(--bg-hover); }
.btn-ghost:disabled { opacity: .45; cursor: not-allowed; }

.chk { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-mid); cursor: pointer; }
.chk input { accent-color: var(--primary); width: 14px; height: 14px; }

.field { display: block; margin-bottom: 13px; }
.field-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-mid); margin-bottom: 6px; }
.field input, .field select {
  width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; font-family: inherit; color: var(--text); background: var(--bg-sub); outline: none;
  transition: border-color .14s, box-shadow .14s;
}
.field input:focus, .field select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pw-wrap { position: relative; }
.pw-toggle {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: transparent; border: none; color: var(--text-dim);
  font-size: 11.5px; cursor: pointer; padding: 3px 7px; border-radius: 6px; font-family: inherit;
}
.pw-toggle:hover { color: var(--primary); }
.search-input, .side-select, .side-search {
  width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; font-family: inherit; color: var(--text); background: var(--bg-sub); outline: none;
  transition: border-color .14s, box-shadow .14s;
}
.search-input:focus, .side-select:focus, .side-search:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
.side-select { margin-bottom: 8px; cursor: pointer; }
.side-file {
  width: 100%; font-size: 12px; color: var(--text-dim);
  border: 1px dashed var(--border); border-radius: 8px;
  padding: 8px; margin-bottom: 8px; background: var(--bg-sub); cursor: pointer;
}
.side-file:hover { border-color: var(--primary); }
.side-note, .side-hint { font-size: 11.5px; line-height: 1.65; color: var(--text-dim); margin: 0 0 9px; }
.side-hint { margin: 6px 0 12px; }
.side-msg { font-size: 12px; min-height: 16px; margin: 4px 0 8px; word-break: break-word; color: var(--text-mid); }
.side-msg.ok { color: var(--ok); }
.side-msg.err { color: var(--primary); }
.side-title { font-size: 11px; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: .06em; margin: 0 0 8px; }
.data-meta { font-size: 12.5px; color: var(--text-mid); margin-bottom: 14px; }
.data-meta .row { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; }
.data-meta .row span:last-child { color: var(--text-dim); font-variant-numeric: tabular-nums; }
.data-meta .sep { border-top: 1px dashed var(--border); margin: 5px 0; }
.conn-status { font-size: 12.5px; color: var(--text-mid); margin-bottom: 8px; }
.conn-status .on { color: var(--ok); font-weight: 650; }
.version { margin-top: auto; padding: 12px 2px; font-size: 11px; color: var(--text-dim); }

/* ====== 表格 ====== */
.table-meta { color: var(--text-mid); font-size: 12.5px; margin: 0 2px 9px; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; min-height: 30px; }
.table-meta .right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.table-wrap {
  border: 1px solid var(--border); border-radius: 12px; overflow: auto;
  max-height: 66vh; background: var(--bg-panel); box-shadow: var(--shadow-1);
}
table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 12.5px; }
thead th {
  position: sticky; top: 0; z-index: 5;
  background: var(--thead); color: var(--text-mid);
  text-align: left; font-weight: 600; font-size: 11px;
  text-transform: uppercase; letter-spacing: .05em;
  padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
tbody td { padding: 8px 12px; border-bottom: 1px solid var(--border-soft); color: var(--text); vertical-align: top; }
tbody td:first-child { font-weight: 550; color: var(--ink); }
tbody tr:nth-child(even) { background: var(--bg-sub); }
html[data-theme="dark"] tbody tr:nth-child(even) { background: rgba(255,255,255,.018); }
tbody tr:hover { background: var(--primary-soft); }
tbody tr:last-child td { border-bottom: none; }
td.wrap { max-width: 460px; white-space: normal; word-break: break-word; color: var(--text-mid); }
.muted { color: var(--text-dim); }

/* 视图切换 */
.view-toggle {
  display: inline-flex; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg-panel); padding: 2px; gap: 2px; box-shadow: var(--shadow-1);
}
.view-btn {
  padding: 5px 12px; border: none; background: transparent; font-size: 12.5px;
  font-family: inherit; color: var(--text-mid); cursor: pointer; border-radius: 6px;
  transition: all .14s; font-weight: 550;
}
.view-btn:hover:not(:disabled) { color: var(--text); }
.view-btn.active { background: var(--primary); color: #fff; }
.view-btn:disabled { opacity: .4; cursor: not-allowed; }

/* 树形（主数据） */
.tree-wrap {
  border: 1px solid var(--border); border-radius: 12px; overflow: hidden;
  max-height: 66vh; background: var(--bg-panel); display: flex; flex-direction: column; box-shadow: var(--shadow-1);
}
.tree-toolbar { display: flex; gap: 8px; padding: 8px 12px; background: var(--bg-sub); border-bottom: 1px solid var(--border-soft); }
.tree-toolbar .btn-ghost { background: var(--bg-panel); }
.tree-head, .tree-row { display: grid; grid-template-columns: minmax(260px, 2.6fr) 1.2fr 1.2fr 80px; align-items: center; }
.tree-head { background: var(--thead); border-bottom: 1px solid var(--border); font-size: 11px; font-weight: 600; color: var(--text-mid); text-transform: uppercase; letter-spacing: .05em; }
.tree-head .tree-cell { padding: 9px 12px; }
.tree-body { overflow: auto; max-height: calc(66vh - 74px); }
.tree-row { font-size: 12.5px; border-bottom: 1px solid var(--border-soft); transition: background .1s; }
.tree-row:nth-child(even) { background: var(--bg-sub); }
html[data-theme="dark"] .tree-row:nth-child(even) { background: rgba(255,255,255,.018); }
.tree-row:hover { background: var(--primary-soft); cursor: pointer; }
.tree-cell { padding: 7px 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-cell.num { text-align: right; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.tree-cell.tree-name {
  display: flex; align-items: center; gap: 5px;
  background-image: repeating-linear-gradient(to right, var(--border) 0 1px, transparent 1px 18px);
  background-size: calc(var(--indent, 0) * 18px) 100%;
  background-repeat: no-repeat; background-position: 13px 0;
}
.tree-label { font-weight: 550; color: var(--ink); }
.tree-alias { color: var(--text-dim); font-size: 12px; margin-left: 7px; }
.tree-count { font-size: 10px; font-weight: 600; color: var(--text-dim); background: var(--bg-hover); border-radius: 99px; padding: 0 6px; margin-left: 6px; line-height: 15px; font-variant-numeric: tabular-nums; }
.tree-caret {
  flex: 0 0 16px; width: 16px; height: 16px; border: none; background: none; padding: 0;
  font-size: 10px; color: var(--text-dim); cursor: pointer; border-radius: 4px;
  display: inline-flex; align-items: center; justify-content: center; transition: all .12s;
}
.tree-caret:hover { background: var(--primary-soft); color: var(--primary); }
.tree-caret.empty { cursor: default; }
.root-badge { display: inline-block; font-size: 10px; font-weight: 700; line-height: 16px; padding: 0 7px; margin-right: 6px; border-radius: 99px; background: var(--primary-soft); color: var(--primary); white-space: nowrap; }
.tree-row.is-root .tree-label { font-weight: 700; }
/* 为补齐层级而合成的中间节点（清单里没有该成员，只作为父级容器出现） */
.syn-badge { display: inline-block; font-size: 10px; font-weight: 700; line-height: 16px; padding: 0 7px; margin-left: 6px; border-radius: 99px; background: var(--bg-hover); color: var(--text-dim); white-space: nowrap; }
.tree-row.is-syn .tree-label { color: var(--text-mid); font-style: italic; }
tbody tr.is-root { background: var(--primary-soft); }

/* 多选 */
.ms { position: relative; }
.ms-box {
  width: 100%; min-height: 38px; padding: 4px 30px 4px 7px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--bg-sub);
  display: flex; flex-wrap: wrap; align-items: center; gap: 5px;
  cursor: pointer; position: relative; transition: border-color .14s, box-shadow .14s;
}
.ms-box:hover { border-color: var(--text-dim); }
.ms-box::after {
  content: ""; position: absolute; right: 13px; top: 50%;
  width: 5px; height: 5px; border-right: 1.5px solid var(--text-dim);
  border-bottom: 1.5px solid var(--text-dim); transform: translateY(-70%) rotate(45deg); pointer-events: none;
}
.ms-box.open { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
.ms-placeholder { color: var(--text-dim); padding: 4px 7px; font-size: 12.5px; }
.ms-chip {
  background: var(--primary-soft); border: 1px solid transparent; border-radius: 99px;
  padding: 2px 6px 2px 10px; font-size: 12px; color: var(--primary); font-weight: 550;
  display: inline-flex; align-items: center; gap: 5px; max-width: 100%;
}
html[data-theme="dark"] .ms-chip { color: var(--primary); }
.ms-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-chip button {
  border: none; background: transparent; color: inherit; width: 14px; height: 14px; line-height: 1;
  border-radius: 50%; cursor: pointer; font-size: 9px; flex: none;
  display: flex; align-items: center; justify-content: center;
}
.ms-chip button:hover { background: rgba(0,0,0,.12); }
html[data-theme="dark"] .ms-chip button:hover { background: rgba(255,255,255,.14); }
.ms-panel {
  display: none; position: absolute; z-index: 60; top: calc(100% + 5px); left: 0;
  width: 100%; max-height: 330px; background: var(--bg-panel); overflow: hidden;
  border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-3);
}
.ms-panel.open { display: block; animation: pop .14s ease-out; }
.ms-search { padding: 8px; border-bottom: 1px solid var(--border-soft); }
.ms-search input {
  width: 100%; padding: 6px 10px; border: 1px solid var(--border); border-radius: 7px;
  font-family: inherit; font-size: 12.5px; outline: none; background: var(--bg-sub); color: var(--text);
}
.ms-search input:focus { border-color: var(--primary); }
.ms-list { max-height: 250px; overflow-y: auto; padding: 5px; }
.ms-item {
  display: flex; align-items: center; gap: 9px; padding: 6px 10px;
  border-radius: 7px; cursor: pointer; font-size: 12.5px; transition: background .1s;
}
.ms-item:hover { background: var(--bg-hover); }
.ms-item input { accent-color: var(--primary); flex: none; width: 14px; height: 14px; }
.ms-item .txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-empty { padding: 16px; color: var(--text-dim); text-align: center; font-size: 12.5px; }

/* 控件卡 */
.controls {
  display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px;
  max-width: 640px; background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: 12px; padding: 13px 14px; box-shadow: var(--shadow-1);
}
.ctl-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ctl-label {
  font-size: 11px; font-weight: 700; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: .06em;
}
.search-input { background: var(--bg-sub); }

/* 空态 / 加载 */
.empty-state {
  padding: 44px 20px; text-align: center; color: var(--text-dim); font-size: 13px;
  border: 1px dashed var(--border); border-radius: 12px; background: var(--bg-sub); line-height: 1.7;
}
.empty-state p { margin: 8px 0 0; }
.empty-state.small { padding: 12px; }
.empty-state .btn { margin-top: 12px; }
.loading { display: flex; align-items: center; gap: 10px; color: var(--text-mid); padding: 14px 2px; font-size: 13px; }
.spinner {
  width: 14px; height: 14px; border: 2px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin .7s linear infinite; flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* EPM 维度浏览 */
.epm-dims-row { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 11px; }
.dim-list {
  list-style: none; margin: 0; padding: 6px; flex: 1;
  display: flex; flex-wrap: wrap; gap: 5px; max-height: 104px; overflow-y: auto;
  border: 1px solid var(--border); border-radius: 12px; background: var(--bg-panel); box-shadow: var(--shadow-1);
}
.dim-list li {
  padding: 4px 11px; border-radius: 99px; font-size: 12px; cursor: pointer;
  color: var(--text-mid); background: var(--bg-hover); white-space: nowrap;
  border: 1px solid transparent; transition: all .12s;
}
.dim-list li:hover { color: var(--text); background: var(--bg-hover); border-color: var(--border); }
.dim-list li.active {
  background: var(--primary); color: #fff; font-weight: 600;
  border-color: var(--primary); box-shadow: 0 1px 4px var(--primary-ring);
}

/* 弹窗 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(10,12,18,.44);
  backdrop-filter: blur(2px); z-index: 70; opacity: 0; pointer-events: none; transition: opacity .18s;
}
.modal-mask.open { opacity: 1; pointer-events: auto; }
.modal {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -46%) scale(.98);
  width: min(840px, calc(100vw - 32px)); max-height: 88vh;
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: var(--shadow-3); z-index: 71; display: flex; flex-direction: column; overflow: hidden;
  opacity: 0; pointer-events: none;
  transition: opacity .18s, transform .2s cubic-bezier(.3, 1.2, .5, 1);
}
.modal.open { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%) scale(1); }
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 20px; border-bottom: 1px solid var(--border);
}
.modal-head h3 { margin: 0; font-size: 14.5px; font-weight: 700; color: var(--ink); display: flex; align-items: center; gap: 8px; }
.modal-body { padding: 18px 22px 20px; overflow-y: auto; }
.modal-hint {
  margin: 0 0 16px; font-size: 12.5px; line-height: 1.75; color: var(--text-mid);
  background: var(--bg-sub); border: 1px solid var(--border-soft);
  border-left: 3px solid var(--primary); border-radius: 8px; padding: 11px 13px;
}
.modal-hint strong { color: var(--ink); }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border-soft); }
.badge-inline { display: inline-block; padding: 1px 10px; border-radius: 99px; background: var(--primary-soft); color: var(--primary); font-weight: 700; font-size: 12px; }
.msg { margin: 10px 0 0; font-size: 12.5px; min-height: 17px; line-height: 1.6; }
.msg.err { color: var(--primary); }
.msg.ok { color: var(--ok); }

/* 刷新目标 */
.refresh-targets { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; margin-bottom: 16px; background: var(--bg-panel); }
.rt-row { display: flex; gap: 11px; padding: 12px 14px; border-bottom: 1px solid var(--border-soft); align-items: flex-start; transition: background .12s; }
.rt-row:last-child { border-bottom: none; }
.rt-row:hover { background: var(--bg-sub); }
.rt-row.disabled { opacity: .6; }
.rt-row > input[type=checkbox] { accent-color: var(--primary); margin-top: 3px; flex: none; width: 15px; height: 15px; }
.rt-main { flex: 1; min-width: 0; }
.rt-name { font-size: 13px; font-weight: 650; color: var(--ink); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rt-tag { font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--primary-soft); color: var(--primary); }
.rt-tag.manual { background: var(--bg-hover); color: var(--text-dim); }
.rt-tag.replace { background: var(--info-soft); color: var(--info); }
.rt-note { font-size: 11.5px; color: var(--text-dim); line-height: 1.6; margin-top: 4px; }
.rt-warn { font-size: 11.5px; line-height: 1.6; margin-top: 7px; padding: 8px 10px; background: var(--warn-soft); border-left: 3px solid var(--warn); border-radius: 6px; color: var(--warn); }
.rt-params { display: flex; gap: 11px; align-items: flex-end; margin-top: 9px; flex-wrap: wrap; }
.rt-params .mini-field { display: flex; flex-direction: column; gap: 3px; }
.rt-params .mini-field span { font-size: 10.5px; font-weight: 600; color: var(--text-dim); }
.rt-params input, .rt-params select {
  padding: 5px 9px; border: 1px solid var(--border); border-radius: 7px;
  font-size: 12px; font-family: inherit; outline: none; color: var(--text); background: var(--bg-sub);
  transition: border-color .14s;
}
.rt-params input { width: 130px; }
.rt-params input:focus, .rt-params select:focus { border-color: var(--primary); }
.pv-item { border: 1px solid var(--border); border-radius: 12px; margin-bottom: 12px; overflow: hidden; background: var(--bg-panel); box-shadow: var(--shadow-1); }
.pv-head { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 11px 13px; background: var(--bg-sub); border-bottom: 1px solid var(--border-soft); flex-wrap: wrap; }
.pv-head strong { font-size: 13px; color: var(--ink); }
.pv-head .meta { font-size: 11px; color: var(--text-dim); }
.pv-body { padding: 12px 13px; }
.pv-stats { display: flex; gap: 17px; flex-wrap: wrap; font-size: 12.5px; }
.pv-stats b { font-size: 14px; font-variant-numeric: tabular-nums; margin-left: 2px; }
.pv-add { color: var(--ok); }
.pv-del { color: var(--primary); }
.pv-chg { color: var(--warn); }
.pv-table { width: 100%; font-size: 11.5px; border-collapse: collapse; margin-top: 8px; }
.pv-table th { background: var(--thead); text-align: left; padding: 5px 9px; font-weight: 600; font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-mid); border-bottom: 1px solid var(--border); white-space: nowrap; }
.pv-table td { padding: 4px 9px; border-bottom: 1px solid var(--border-soft); word-break: break-word; }
.pv-table .old { color: var(--primary); }
.pv-table .new { color: var(--ok); font-weight: 600; }
.pv-empty { font-size: 12.5px; color: var(--text-dim); margin: 4px 0 0; }
details.pv-detail { margin-top: 9px; }
details.pv-detail summary { cursor: pointer; font-size: 12px; color: var(--text-dim); padding: 3px 0; outline: none; }
details.pv-detail summary:hover { color: var(--primary); }
.pv-err { background: var(--primary-soft); border-left: 3px solid var(--primary); padding: 10px 12px; border-radius: 7px; font-size: 12.5px; color: var(--text); line-height: 1.7; }
.backup-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 2px; border-bottom: 1px solid var(--border-soft); font-size: 13px; }
.backup-row:last-child { border-bottom: none; }
.backup-row .t { color: var(--text-dim); font-size: 11.5px; margin-top: 2px; }

/* 操作日志 */
.oplog-modal { width: min(960px, calc(100vw - 32px)); }
.oplog-body { padding: 14px 18px 18px; }
.oplog-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 11px; flex-wrap: wrap; }
.oplog-select { padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 12.5px; font-family: inherit; background: var(--bg-sub); color: var(--text); outline: none; cursor: pointer; }
.oplog-meta { font-size: 11.5px; color: var(--text-dim); }
.oplog-list { max-height: 60vh; overflow: auto; }
.oplog-table { width: 100%; font-size: 12.5px; border-collapse: collapse; }
.oplog-table th {
  position: sticky; top: 0; z-index: 2; background: var(--thead); text-align: left; padding: 7px 10px;
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-mid); border-bottom: 1px solid var(--border); white-space: nowrap;
}
.oplog-table td { padding: 6px 10px; border-bottom: 1px solid var(--border-soft); vertical-align: top; color: var(--text); }
.oplog-table tbody tr:hover { background: var(--primary-soft); }
.oplog-table .t-ts { white-space: nowrap; color: var(--text-mid); font-variant-numeric: tabular-nums; }
.oplog-table .t-act { white-space: nowrap; }
.oplog-table .t-ms { text-align: right; color: var(--text-dim); font-variant-numeric: tabular-nums; white-space: nowrap; }
.oplog-tag { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 10.5px; font-weight: 700; white-space: nowrap; }
.oplog-tag.ok { background: var(--ok-soft); color: var(--ok); }
.oplog-tag.fail { background: var(--primary-soft); color: var(--primary); }
.oplog-tag.partial { background: var(--warn-soft); color: var(--warn); }
.oplog-tag.warn { background: var(--warn-soft); color: var(--warn); }
.oplog-detail { color: var(--text-dim); font-size: 11.5px; max-width: 320px; word-break: break-word; }

/* 抽屉 */
.drawer-mask {
  position: fixed; inset: 0; background: rgba(10,12,18,.38);
  backdrop-filter: blur(2px); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 60;
}
.drawer-mask.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 460px; max-width: 92vw;
  background: var(--bg-panel); border-left: 1px solid var(--border);
  transform: translateX(100%); transition: transform .26s cubic-bezier(.4, 0, .2, 1);
  z-index: 61; display: flex; flex-direction: column; box-shadow: -16px 0 44px rgba(10,12,18,.16);
}
.drawer.open { transform: translateX(0); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.drawer-head h3 { margin: 0; font-size: 14.5px; font-weight: 700; color: var(--ink); }
.drawer-body { padding: 16px 20px; overflow-y: auto; flex: 1; }
.kv { display: flex; padding: 9px 0; border-bottom: 1px solid var(--border-soft); gap: 14px; align-items: baseline; }
.kv:last-child { border-bottom: none; }
.kv-k { flex: 0 0 130px; font-size: 11.5px; color: var(--text-dim); font-weight: 600; word-break: break-word; }
.kv-v { flex: 1; font-size: 13px; color: var(--text); word-break: break-word; font-variant-numeric: tabular-nums; }
.kv-v pre { margin: 0; white-space: pre-wrap; font-size: 11.5px; background: var(--bg-sub); padding: 10px; border-radius: 8px; border: 1px solid var(--border-soft); font-family: Consolas, monospace; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 34px; transform: translate(-50%, 22px) scale(.97);
  background: var(--ink); color: var(--bg);
  padding: 10px 19px; border-radius: 99px; font-size: 13px; font-weight: 550; z-index: 120;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  max-width: 80vw; text-align: center; box-shadow: var(--shadow-3);
}
html[data-theme="dark"] .toast { background: #2a2e3c; color: #e8eaf2; }
.toast.show { opacity: 1; transform: translate(-50%, 0) scale(1); }
.toast.err { background: var(--primary); color: #fff; }
.toast.ok { background: var(--ok); color: #fff; }

/* 门禁 */
.gate-mask {
  position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  background-image: radial-gradient(circle at 20% 20%, var(--primary-soft) 0%, transparent 42%),
                    radial-gradient(circle at 82% 78%, var(--primary-soft) 0%, transparent 42%);
}
.gate-card {
  width: min(400px, 90vw); background: var(--bg-panel); border-radius: 18px;
  border: 1px solid var(--border); box-shadow: var(--shadow-3);
  padding: 34px 34px 28px; text-align: center;
}
.gate-logo {
  width: 50px; height: 50px; margin: 0 auto 12px; border-radius: 14px;
  background: linear-gradient(135deg, var(--primary), #8b5cf6); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 22px;
}
.gate-card h2 { margin: 0 0 8px; font-size: 19px; letter-spacing: -.02em; color: var(--ink); }
.gate-tip { font-size: 12px; line-height: 1.8; color: var(--text-dim); margin: 0 0 16px; }
.gate-card .search-input { margin-bottom: 12px; text-align: center; letter-spacing: 2px; }
.gate-card .msg { margin-top: 10px; }

/* ====== 数据查询（DQ） ====== */
.dq-topbar { margin-bottom: 14px; display: flex; flex-direction: column; gap: 10px; }
.dq-layout { display: grid; grid-template-columns: 232px 1fr; gap: 14px; align-items: start; }
.dq-side {
  border: 1px solid var(--border); border-radius: 12px; background: var(--bg-panel);
  box-shadow: var(--shadow-1); overflow: hidden;
}
.dq-side-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 12px; background: var(--bg-sub); border-bottom: 1px solid var(--border-soft);
  font-size: 11px; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: .06em;
}
.dq-scope {
  display: flex; align-items: center; gap: 7px; padding: 7px 12px;
  font-size: 11.5px; color: var(--text-dim); border-bottom: 1px solid var(--border-soft); cursor: pointer;
}
.dq-scope:hover { color: var(--text-mid); background: var(--bg-sub); }
.dq-scope input { accent-color: var(--primary); width: 14px; height: 14px; }
.dq-list { max-height: 58vh; overflow-y: auto; padding: 6px; }
.dq-item {
  position: relative; padding: 8px 26px 8px 10px; border-radius: 8px;
  cursor: pointer; border: 1px solid transparent; transition: background .12s, border-color .12s;
}
.dq-item:hover { background: var(--bg-hover); }
.dq-item.active { background: var(--primary-soft); border-color: transparent; }
.dq-item-title { font-size: 12.5px; font-weight: 600; color: var(--ink); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.dq-item.active .dq-item-title { color: var(--primary); }
.dq-item-meta { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.dq-del {
  position: absolute; right: 5px; top: 7px; border: none; background: transparent;
  color: var(--text-dim); cursor: pointer; font-size: 11px; line-height: 1;
  padding: 3px 5px; border-radius: 5px;
}
.dq-del:hover { background: var(--primary-soft); color: var(--primary); }
.dq-empty { padding: 22px 12px; text-align: center; color: var(--text-dim); font-size: 12.5px; line-height: 1.7; }
.dq-empty.small { padding: 12px; }
.dq-empty span { color: var(--text-dim); font-size: 11.5px; }

.dq-main { min-width: 0; }
.dq-head { display: flex; gap: 9px; margin-bottom: 12px; flex-wrap: wrap; }
.dq-name { flex: 1; min-width: 200px; }
.dq-mini { max-width: 150px; }
.dq-editor {
  border: 1px solid var(--border); border-radius: 12px; background: var(--bg-panel);
  box-shadow: var(--shadow-1); padding: 13px 14px; margin-bottom: 12px;
}
.dq-block { margin-bottom: 15px; }
.dq-block:last-child { margin-bottom: 0; }
.dq-block-title {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  font-size: 11px; font-weight: 700; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px;
}
.dq-block-title .hint { font-size: 11px; font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--text-dim); }
.dq-pov { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 6px; }
.dq-pov-row { display: grid; grid-template-columns: 96px 1fr 54px auto; align-items: center; gap: 7px; padding: 3px 0; }
.dq-pov-row.key .dq-dim { color: var(--primary); font-weight: 700; }
.dq-pov-row.muted-row { opacity: .5; }
.dq-dim { font-size: 12.5px; color: var(--text-mid); font-weight: 600; }
.dq-note {
  display: inline-flex; align-items: center; justify-content: center;
  width: 13px; height: 13px; margin-left: 5px; border-radius: 50%;
  background: var(--bg-hover); color: var(--text-dim);
  font-size: 9px; font-weight: 700; cursor: help;
}
.dq-note:hover { background: var(--primary-soft); color: var(--primary); }
.dq-used { font-size: 10.5px; color: var(--text-dim); white-space: nowrap; }
.dq-input, .dq-select {
  width: 100%; padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 12.5px; font-family: inherit; color: var(--text); background: var(--bg-sub); outline: none;
  transition: border-color .14s, box-shadow .14s;
}
.dq-input:focus, .dq-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); background: var(--bg-panel); }
.dq-input:disabled { background: var(--bg-hover); color: var(--text-dim); }
.dq-select { cursor: pointer; }
.dq-axis { display: flex; flex-direction: column; gap: 7px; }
.dq-axis-row { display: grid; grid-template-columns: 150px 1fr 168px 54px 30px; align-items: center; gap: 7px; }
.dq-pick { padding: 5px 9px; font-size: 12px; }
.dq-remove { padding: 4px 8px; font-size: 11px; color: var(--text-dim); }
.dq-remove:hover { color: var(--primary); }
.dq-actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; margin-bottom: 10px; }
.dq-chk { margin: 0; padding: 0; }

.dq-result { margin-top: 4px; }
.dq-summary {
  background: var(--bg-sub); border: 1px solid var(--border-soft);
  border-left: 3px solid var(--primary); border-radius: 10px;
  padding: 9px 12px; margin-bottom: 10px;
}
.dq-summary-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.dq-summary-row.dim { font-size: 12px; color: var(--text-dim); margin-top: 6px; display: block; }
.dq-pov-chip {
  display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 99px;
  background: var(--bg-panel); border: 1px solid var(--border); color: var(--text-mid);
  font-variant-numeric: tabular-nums;
}
.dq-table-wrap { max-height: 58vh; }
.dq-table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 12.5px; }
.dq-table thead th {
  position: sticky; top: 0; z-index: 3; background: var(--thead);
  padding: 8px 11px; text-align: right; font-size: 11px; font-weight: 700;
  color: var(--text-mid); border-bottom: 1px solid var(--border); white-space: nowrap;
  text-transform: uppercase; letter-spacing: .04em;
}
.dq-table thead th.dq-rowhead, .dq-table td.dq-rowhead { text-align: left; }
.dq-table td {
  padding: 6px 11px; text-align: right; border-bottom: 1px solid var(--border-soft);
  font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--text);
}
.dq-table td.dq-rowhead { font-weight: 600; color: var(--ink); background: var(--bg-panel); position: sticky; left: 0; z-index: 2; }
.dq-table thead th.dq-rowhead { position: sticky; left: 0; z-index: 4; }
.dq-table td.tight { padding: 6px 7px; font-size: 12px; }
.dq-table tbody tr:nth-child(even) td { background: var(--bg-sub); }
.dq-table tbody tr:nth-child(even) td.dq-rowhead { background: var(--bg-panel); }
.dq-table tbody tr:hover td { background: var(--primary-soft); }

.dq-res-toolbar { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; margin-bottom: 10px; }
.dq-chart-type { width: auto; min-width: 106px; padding: 5px 9px; font-size: 12.5px; }
.dq-chart-hint { font-size: 11.5px; color: var(--text-dim); }
.dq-res-actions { margin-left: auto; display: flex; gap: 8px; }
.dq-chart-wrap {
  border: 1px solid var(--border); border-radius: 12px; background: var(--bg-panel);
  box-shadow: var(--shadow-1); padding: 10px; margin-bottom: 10px;
}
.dq-chart { width: 100%; height: 420px; }

.dq-analysis-wrap { margin-top: 4px; }
.dq-an-block { margin-bottom: 16px; }
.dq-an-block .hint { font-size: 11px; font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--text-dim); }
.dq-an-col { display: inline-block; vertical-align: top; margin: 0 14px 12px 0; min-width: 300px; max-width: 46%; }
.dq-an-col strong { font-size: 13px; color: var(--ink); }
.dq-an-table { margin-top: 6px; }

.dq-his-modal { width: min(700px, calc(100vw - 32px)); }
.dq-his-list { max-height: 50vh; overflow-y: auto; }
.dq-his-item {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  padding: 9px 12px; border: 1px solid var(--border-soft);
  border-radius: 10px; margin-bottom: 7px; transition: background .12s;
}
.dq-his-item:hover { background: var(--bg-sub); }
.dq-his-when { font-size: 12.5px; font-weight: 600; color: var(--ink); display: flex; align-items: center; gap: 6px; min-width: 168px; font-variant-numeric: tabular-nums; }
.dq-his-cur { font-size: 10px; font-weight: 700; color: var(--primary); background: var(--primary-soft); border-radius: 99px; padding: 1px 7px; }
.dq-his-meta { flex: 1; font-size: 11.5px; color: var(--text-dim); }

.dq-map-modal { width: min(760px, calc(100vw - 32px)); }
.dq-map-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.dq-map-toolbar .search-input { flex: 1; }
.dq-map-tools { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.dq-map-tools .btn-ghost { padding: 4px 9px; font-size: 11.5px; }
.dq-map-list { border: 1px solid var(--border); border-radius: 10px; overflow-y: auto; max-height: 46vh; padding: 4px; }
.dq-map-item {
  display: grid; grid-template-columns: 20px 1fr auto; align-items: center; gap: 9px;
  padding: 6px 9px; border-radius: 7px; cursor: pointer; font-size: 12.5px;
}
.dq-map-item:hover { background: var(--bg-hover); }
.dq-map-item.on { background: var(--primary-soft); }
.dq-map-item input { accent-color: var(--primary); }
.dq-map-item .nm { color: var(--text); font-weight: 550; overflow: hidden; text-overflow: ellipsis; }
.dq-map-item .al { color: var(--text-dim); font-size: 11.5px; }
.dq-map-more { padding: 8px; text-align: center; color: var(--text-dim); font-size: 11.5px; }
.modal-actions #dqMapSel { margin-right: auto; }

.dq-tree-item {
  display: flex; align-items: center; gap: 7px;
  padding: 4px 8px 4px 0; border-radius: 7px; cursor: pointer;
  font-size: 12.5px; transition: background .1s;
}
.dq-tree-item:hover { background: var(--bg-hover); }
.dq-tree-item.on { background: var(--primary-soft); }
.dq-tree-item input[type=checkbox] { accent-color: var(--primary); flex: none; width: 14px; height: 14px; }
.dq-tree-item .nm { color: var(--text); font-weight: 550; }
.dq-tree-item .al { color: var(--text-dim); font-size: 11.5px; margin-left: 2px; }
.dq-tree-caret {
  flex: 0 0 16px; width: 16px; height: 16px; border: none; background: none; padding: 0;
  font-size: 10px; color: var(--text-dim); cursor: pointer; border-radius: 4px;
  display: inline-flex; align-items: center; justify-content: center; transition: all .12s;
}
.dq-tree-caret:hover { background: var(--primary-soft); color: var(--primary); }
.dq-tree-caret.empty { cursor: default; }
.dq-tree-cnt { font-size: 10px; font-weight: 600; color: var(--text-dim); background: var(--bg-hover); border-radius: 99px; padding: 0 6px; line-height: 14px; font-variant-numeric: tabular-nums; }

/* NLQ 智能查询条 */
.nlq-bar {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--bg-panel); box-shadow: var(--shadow-1);
  padding: 11px 13px; margin-top: 12px;
}
.nlq-input { flex: 1; min-width: 300px; font-size: 13.5px; }
.dq-prompt-text {
  width: 100%; height: 150px; margin: 6px 0 10px; padding: 10px;
  border: 1px solid var(--border); border-radius: 10px;
  font-family: Consolas, monospace; font-size: 11.5px; color: var(--text);
  background: var(--bg-sub); resize: vertical;
}
.dq-prompt-paste { margin-top: 6px; }
.dq-prompt-paste .dq-prompt-text { height: 90px; }
.modal-actions #dqMapSel { margin-right: auto; }

/* 响应式 */
/* ==========================================================================
   数据探查 · 6 步引导（static/explore.js）
   ========================================================================== */
.ex-stepper {
  display: flex; align-items: center; flex-wrap: wrap; gap: 2px;
  padding: 10px 12px; margin-bottom: 10px;
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: 12px;
}
.ex-step {
  appearance: none; border: none; background: transparent; cursor: pointer; font-family: inherit;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 10px; border-radius: 8px; color: var(--text-dim);
  font-size: 12px; font-weight: 550; transition: all .14s;
}
.ex-step:hover { background: var(--bg-hover); color: var(--text); }
.ex-step-n {
  flex: none; width: 19px; height: 19px; border-radius: 99px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums;
  background: var(--bg-hover); color: var(--text-dim);
}
.ex-step.current { color: var(--primary); background: var(--primary-soft); font-weight: 650; }
.ex-step.current .ex-step-n { background: var(--primary); color: #fff; }
.ex-step.done { color: var(--ok); }
.ex-step.done .ex-step-n { background: var(--ok); color: #fff; }
.ex-step-sep { width: 10px; height: 1px; background: var(--border); flex: none; }
.ex-step-l { white-space: nowrap; }

.ex-guide {
  padding: 13px 15px; margin-bottom: 12px;
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-1);
}
.ex-guide-head { display: flex; align-items: baseline; gap: 9px; flex-wrap: wrap; margin-bottom: 9px; }
.ex-guide-n {
  flex: none; font-size: 10.5px; font-weight: 700; letter-spacing: .04em;
  color: var(--primary); background: var(--primary-soft); border-radius: 99px; padding: 2px 8px;
}
.ex-guide-head strong { font-size: 14px; font-weight: 650; color: var(--ink); }
.ex-guide-d { font-size: 12px; color: var(--text-dim); }

.ex-text {
  width: 100%; box-sizing: border-box; resize: vertical;
  font-family: inherit; font-size: 14px; line-height: 1.5;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px;
  background: var(--bg); color: var(--text);
}
.ex-text:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.ex-examples { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 12px; color: var(--text-dim); margin-top: 7px; }
.ex-chip {
  appearance: none; cursor: pointer; font-family: inherit; font-size: 12px;
  background: var(--bg-hover); color: var(--text-mid); border: 1px solid var(--border);
  border-radius: 99px; padding: 3px 10px; transition: all .14s;
}
.ex-chip:hover { border-color: var(--primary); color: var(--primary); }
.ex-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 11px; }
.ex-actions-sep { width: 1px; height: 18px; background: var(--border); margin: 0 2px; }

.ex-parse { display: flex; flex-direction: column; gap: 6px; }
.ex-parse-row { display: flex; gap: 10px; align-items: flex-start; font-size: 12.5px; }
.ex-k { flex: none; width: 62px; color: var(--text-dim); padding-top: 1px; }
.ex-hits { display: flex; flex-wrap: wrap; gap: 5px; }
.ex-hit {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--bg-hover); border-radius: 7px; padding: 3px 8px; font-size: 12px;
}
.ex-hit b { color: var(--primary); font-weight: 650; }
.ex-hit i { font-style: normal; color: var(--text-dim); font-size: 11px; opacity: .8; }
.ex-unmatched { color: var(--warn, #b45309); }
.ex-mono { font-family: var(--font-mono, ui-monospace, Consolas, monospace); font-size: 12px; word-break: break-all; }
.ex-note { font-size: 12px; color: var(--text-dim); margin: 0 0 8px; }
.ex-ok { font-size: 12.5px; color: var(--ok); background: var(--bg-hover); border-radius: 8px; padding: 8px 10px; }
.ex-warn { font-size: 12.5px; color: #b45309; background: var(--bg-hover); border-radius: 8px; padding: 8px 10px; }
.ex-an-table { margin-top: 8px; }
.ex-an-table td, .ex-an-table th { font-size: 12.5px; }

/* 向导模式：默认收起维度编辑器，需要时在步骤 2 展开 */
[data-panel="__dq"].ex-guide-on .dq-editor { display: none; }
[data-panel="__dq"].ex-guide-on.ex-show-editor .dq-editor { display: block; }
[data-panel="__dq"].ex-guide-on .nlq-bar { display: none; }

/* ==========================================================================
   关键字映射表表单（static/explore.js）
   ========================================================================== */
.nlr-modal { width: min(1180px, 94vw); max-width: 1180px; }
.nlr-body { max-height: 78vh; overflow: auto; }
.nlr-sub { font-size: 11px; font-weight: 600; color: var(--text-dim); margin-left: 6px; }
.nlr-head-actions { display: flex; gap: 6px; align-items: center; }

.nlr-cats { display: flex; gap: 4px; flex-wrap: wrap; margin: 10px 0 12px; }
.nlr-cat {
  appearance: none; cursor: pointer; font-family: inherit; font-size: 12.5px; font-weight: 550;
  background: transparent; color: var(--text-mid); border: 1px solid var(--border);
  border-radius: 8px; padding: 5px 11px; display: inline-flex; align-items: center; gap: 6px;
  transition: all .14s;
}
.nlr-cat:hover { color: var(--text); border-color: var(--text-dim); }
.nlr-cat.active { color: var(--primary); border-color: var(--primary); background: var(--primary-soft); font-weight: 650; }
.nlr-cat-n {
  font-size: 10.5px; font-weight: 600; background: var(--bg-hover);
  border-radius: 99px; padding: 0 6px; line-height: 15px; color: var(--text-dim);
}
.nlr-cat.active .nlr-cat-n { background: transparent; color: var(--primary); }

.nlr-cat-hint { font-size: 12px; color: var(--text-dim); margin-bottom: 7px; }
.nlr-cat-hint strong { color: var(--text-mid); }
.nlr-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; }
.nlr-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.nlr-table th, .nlr-table td { padding: 5px 7px; text-align: left; vertical-align: middle; white-space: nowrap; }
.nlr-table thead th {
  background: #f4f6f9; color: var(--text-dim); font-size: 11px; font-weight: 650;
  letter-spacing: .03em; position: sticky; top: 0; z-index: 1;
}
.nlr-table thead th.req::after { content: " *"; color: var(--primary); }
.nlr-table tbody tr { border-top: 1px solid var(--border); }
.nlr-table tbody tr:hover { background: var(--bg-hover); }
.nlr-table tr.dirty { background: #fff8e6; }
.nlr-table tr.nlr-new { background: #eef6ff; }
.nlr-ord { width: 62px; }
.nlr-idx { font-size: 11px; color: var(--text-dim); font-variant-numeric: tabular-nums; margin-right: 3px; }
.nlr-mv { display: inline-flex; flex-direction: column; gap: 0; vertical-align: middle; }
.nlr-mv button {
  appearance: none; border: none; background: transparent; cursor: pointer;
  font-size: 8px; line-height: 8px; color: var(--text-dim); padding: 0 2px;
}
.nlr-mv button:hover:not(:disabled) { color: var(--primary); }
.nlr-mv button:disabled { opacity: .25; cursor: default; }

.nlr-input {
  width: 100%; min-width: 130px; box-sizing: border-box; font-family: inherit;
  font-size: 12.5px; padding: 4px 7px; border: 1px solid var(--border);
  border-radius: 6px; background: var(--bg-panel); color: var(--text);
}
.nlr-input:focus { outline: 2px solid var(--primary); outline-offset: 0; }
.nlr-select { min-width: 108px; }
.nlr-who { width: 92px; font-size: 11px; color: var(--text-dim); white-space: nowrap; }
.nlr-time { font-size: 10px; opacity: .75; }
.nlr-act { width: 52px; text-align: right; }
.nlr-del {
  appearance: none; border: none; background: transparent; cursor: pointer;
  font-family: inherit; font-size: 11.5px; color: var(--text-dim); padding: 2px 4px; border-radius: 5px;
}
.nlr-del:hover { color: #d33; background: var(--bg-hover); }
.nlr-ro { display: inline-block; padding: 2px 4px; color: var(--text-mid); }
.nlr-missing { color: #b45309; font-size: 11.5px; }
.nlr-empty { text-align: center; color: var(--text-dim); padding: 18px 0; }

.nlr-foot {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-top: 12px; padding-top: 11px; border-top: 1px solid var(--border);
}
.nlr-foot-spacer { flex: 1; }
.nlr-dirty { font-size: 12px; color: #b45309; }

/* ====== 对比口径（环比 / 同比 / YTD）====== */
.dq-cmp-bar, .ex-cmp {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  padding: 9px 11px; background: var(--bg-hover); border-radius: 9px;
}
.dq-cmp-select { max-width: 300px; }
.dq-cmp-hint { font-size: 11.5px; color: var(--text-dim); }
.dq-cmp-spacer { flex: 1; min-width: 0; }
.dq-cmp-meta { font-size: 12.5px; color: var(--text-mid); margin-top: 7px; }
.dq-cmp-meta strong { color: var(--ink); font-weight: 650; }
.ex-cmp { margin-bottom: 9px; }
/* 涨跌配色：按中文财务习惯 —— **涨=红、跌=绿**（与欧美相反）。
   ⚠️ 不要用 .oplog-tag.ok/.fail：那是「成功/失败」的状态语义，不是涨跌。 */
:root, html[data-theme="light"] { --up: #d0332b; --up-soft: #fdecea; --down: #12864a; --down-soft: #e9f7ee; }
html[data-theme="dark"] { --up: #ff6b60; --up-soft: rgba(255,107,96,.16); --down: #35c47f; --down-soft: rgba(53,196,127,.16); }
.oplog-tag.up { background: var(--up-soft); color: var(--up); }
.oplog-tag.down { background: var(--down-soft); color: var(--down); }
.dq-an-table td.c-up { color: var(--up); font-variant-numeric: tabular-nums; }
.dq-an-table td.c-down { color: var(--down); font-variant-numeric: tabular-nums; }

@media (max-width: 1180px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 8px 14px; row-gap: 6px; }
  .icon-btn.nav-toggle { display: inline-flex; }
  .shell { flex-direction: column; }
  .sidenav {
    display: none; position: static;
    width: 100%; max-height: none; overflow: visible;
    padding: 12px 14px 16px;
    border-right: none; border-bottom: 1px solid var(--border);
    background: var(--bg-panel);
  }
  .shell.nav-open .sidenav { display: block; }
  .nav-children { margin-left: 8px; }
  .workspace { padding: 16px 18px 50px; width: 100%; }
  .dq-layout { grid-template-columns: 1fr; }
  .dq-list { max-height: 30vh; }
  .dq-axis-row { grid-template-columns: 120px 1fr 140px 50px 30px; }
}
@media (max-width: 900px) {
  .dq-pov { grid-template-columns: 1fr; }
  .dq-axis-row { grid-template-columns: 1fr 1fr; }
  .dq-pov-row { grid-template-columns: 82px 1fr 50px; }
  .stat-strip { grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); gap: 8px; }
  .grid2 { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
