/* 深色数据控制台 —— 布局与组件
 * 色值一律走 tokens.css 的变量，本文件不出现裸 hex。
 */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button, textarea, input { font-family: inherit; font-size: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* 滚动条：细、暗、不抢戏 */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--r-full);
  border: 3px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--ink-4); background-clip: padding-box; }

/* ─── 顶栏 ────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-5);
  padding: 0 var(--sp-5);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }

.brand-dot {
  width: 8px; height: 8px;
  border-radius: var(--r-full);
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent);
  flex: 0 0 auto;
}

.brand-name { font-size: var(--fs-lg); font-weight: 600; letter-spacing: 0.01em; }

.brand-sub {
  font-size: var(--fs-xs);
  color: var(--ink-3);
  padding-left: var(--sp-3);
  border-left: 1px solid var(--border-strong);
}

.topbar-right { display: flex; align-items: center; gap: var(--sp-4); }

/* 经营看板入口。用强调色描边而非实心填充：它是个导航入口，
 * 不该比页面主内容（对话）更抢眼。 */
.board-link {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-sm);
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
  padding: var(--sp-2) var(--sp-4);
  background: var(--accent-dim);
  border: 1px solid transparent;
  border-radius: var(--r-full);
  transition: border-color var(--dur) var(--ease),
              background var(--dur) var(--ease);
}

.board-link:hover {
  border-color: var(--accent);
  background: var(--accent-wash);
}

.board-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* 窄屏只留图标，标签让位给状态灯 */
@media (max-width: 760px) {
  .board-link { padding: var(--sp-2); }
  .board-link .label { display: none; }
}

/* 服务状态指示灯 */
.deps {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-2) var(--sp-4);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  cursor: pointer;
  transition: border-color var(--dur) var(--ease);
}
.deps:hover { border-color: var(--border-strong); }

.dep {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-xs);
  color: var(--ink-3);
  white-space: nowrap;
}

.dep i {
  width: 6px; height: 6px;
  border-radius: var(--r-full);
  background: var(--ink-4);
  flex: 0 0 auto;
  transition: background var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.dep[data-state="ok"]   i { background: var(--accent); box-shadow: 0 0 6px var(--accent); }
.dep[data-state="slow"] i { background: var(--warn);   box-shadow: 0 0 6px var(--warn); }
.dep[data-state="down"] i { background: var(--bad);    box-shadow: 0 0 6px var(--bad); }
.dep[data-state="ok"]   { color: var(--ink-2); }
.dep[data-state="down"] { color: var(--bad); }

.dep[data-state="probing"] i { animation: pulse 1.2s var(--ease) infinite; }
@keyframes pulse { 0%,100% { opacity: 0.3; } 50% { opacity: 1; } }

.kbd-hint {
  font-family: var(--mono);
  font-size: var(--fs-xs);
  color: var(--ink-4);
  padding: 2px var(--sp-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
}

/* ─── 三栏骨架 ────────────────────────────────────────────── */
.shell {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
}

/* ─── 侧栏 ────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  min-height: 0;
}

.new-chat {
  margin: var(--sp-4);
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface-2);
  color: var(--ink-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  cursor: pointer;
  text-align: left;
  transition: all var(--dur) var(--ease);
}
.new-chat:hover { background: var(--surface-3); color: var(--ink); border-color: var(--accent); }

.history {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 0 var(--sp-3) var(--sp-4);
  min-height: 0;
}

.history-group {
  font-size: var(--fs-xs);
  color: var(--ink-4);
  padding: var(--sp-4) var(--sp-3) var(--sp-2);
  letter-spacing: 0.04em;
}

.history-item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  width: 100%;
  padding: var(--sp-2) var(--sp-3);
  margin-bottom: 1px;
  background: none;
  border: none;
  border-radius: var(--r-md);
  color: var(--ink-2);
  font-size: var(--fs-sm);
  cursor: pointer;
  text-align: left;
  transition: background var(--dur-fast) var(--ease);
}
.history-item:hover { background: var(--surface-2); color: var(--ink); }
.history-item.active { background: var(--surface-3); color: var(--ink); }

.history-item .route-dot {
  width: 5px; height: 5px;
  border-radius: var(--r-full);
  flex: 0 0 auto;
}
.route-dot[data-route="business"] { background: var(--accent); }
.route-dot[data-route="product"]  { background: var(--accent-2); }
.route-dot[data-route="chat"]     { background: var(--ink-4); }

.history-item .txt {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item .del {
  flex: 0 0 auto;
  opacity: 0;
  background: none;
  border: none;
  color: var(--ink-4);
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  border-radius: var(--r-sm);
}
.history-item:hover .del { opacity: 1; }
.history-item .del:hover { color: var(--bad); }

.history-empty {
  padding: var(--sp-5) var(--sp-3);
  font-size: var(--fs-sm);
  color: var(--ink-4);
  line-height: 1.7;
}

.sidebar-foot { padding: var(--sp-3) var(--sp-4); border-top: 1px solid var(--border); }

.linkbtn {
  background: none;
  border: none;
  color: var(--ink-4);
  font-size: var(--fs-xs);
  cursor: pointer;
  padding: var(--sp-1) 0;
}
.linkbtn:hover { color: var(--bad); }

/* ─── 中栏：对话 ──────────────────────────────────────────── */
.chat-col {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.chat-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--sp-6) var(--sp-7);
  min-height: 0;
}

.thread { max-width: 860px; margin: 0 auto; }

/* 零态欢迎屏 */
.zero {
  max-width: 640px;
  margin: 0 auto;
  padding: 8vh 0 var(--sp-7);
  text-align: center;
}
.zero.hidden { display: none; }

.zero-title {
  font-size: 30px;
  font-weight: 600;
  margin: 0 0 var(--sp-4);
  letter-spacing: -0.01em;
}

.zero-sub {
  color: var(--ink-3);
  margin: 0 auto var(--sp-7);
  max-width: 460px;
  line-height: 1.7;
}

.zero-groups {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-5);
  text-align: left;
}

.zero-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-4);
}

.zero-group-head {
  font-size: var(--fs-xs);
  color: var(--ink-4);
  letter-spacing: 0.04em;
  margin-bottom: var(--sp-3);
}

.chip {
  display: block;
  width: 100%;
  text-align: left;
  padding: var(--sp-2) var(--sp-3);
  margin-bottom: var(--sp-1);
  background: none;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  color: var(--ink-2);
  font-size: var(--fs-sm);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
}
.chip:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
  color: var(--ink);
}

/* 一轮问答 */
.turn { margin-bottom: var(--sp-7); }

.q {
  display: flex;
  gap: var(--sp-4);
  margin-bottom: var(--sp-5);
  align-items: baseline;
}
.q-mark {
  flex: 0 0 auto;
  color: var(--ink-4);
  font-size: var(--fs-sm);
  font-family: var(--mono);
  padding-top: 2px;
}
.q-text {
  font-size: var(--fs-xl);
  font-weight: 500;
  line-height: 1.5;
  letter-spacing: -0.01em;
  white-space: pre-wrap;
  word-break: break-word;
  min-width: 0;
}

.a { padding-left: 28px; }

.a-text {
  line-height: 1.75;
  word-break: break-word;
}
.a-text > *:first-child { margin-top: 0; }
.a-text > *:last-child { margin-bottom: 0; }
.a-text p { margin: 0 0 var(--sp-4); }
.a-text strong { color: var(--ink); font-weight: 600; }
.a-text code {
  font-family: var(--mono);
  font-size: 0.92em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 1px 5px;
  color: var(--accent-2);
}
.a-text ul { margin: 0 0 var(--sp-4); padding-left: var(--sp-6); }
.a-text li { margin-bottom: var(--sp-2); }
.a-text li::marker { color: var(--ink-4); }

/* 打字光标 */
.caret {
  display: inline-block;
  width: 2px;
  height: 1.05em;
  background: var(--accent);
  vertical-align: text-bottom;
  animation: blink 1s steps(2) infinite;
}
@keyframes blink { 0%, 50% { opacity: 1; } 50.01%, 100% { opacity: 0; } }

/* 思考中 */
.thinking {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  color: var(--ink-3);
  font-size: var(--fs-sm);
}
.thinking .dots { display: inline-flex; gap: 3px; }
.thinking .dots i {
  width: 4px; height: 4px;
  border-radius: var(--r-full);
  background: var(--accent);
  animation: bounce 1.2s var(--ease) infinite;
}
.thinking .dots i:nth-child(2) { animation-delay: 0.15s; }
.thinking .dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* 回答底部的元信息行 */
.a-meta {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-top: var(--sp-5);
  flex-wrap: wrap;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-xs);
  padding: 2px var(--sp-3);
  border-radius: var(--r-full);
  border: 1px solid var(--border-strong);
  color: var(--ink-3);
  white-space: nowrap;
}
.tag[data-route="business"] {
  color: var(--accent);
  border-color: var(--accent-dim);
  background: var(--accent-dim);
}
.tag[data-route="product"] {
  color: var(--accent-2);
  border-color: var(--border-strong);
}

.tag .dot { width: 5px; height: 5px; border-radius: var(--r-full); background: currentColor; }

.a-meta .ms { font-size: var(--fs-xs); color: var(--ink-4); font-variant-numeric: tabular-nums; }

.openpanel {
  background: none;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-full);
  color: var(--ink-3);
  font-size: var(--fs-xs);
  padding: 2px var(--sp-3);
  cursor: pointer;
}
.openpanel:hover { color: var(--accent); border-color: var(--accent); }

/* 降级横幅：状态必须配图标+文字，不靠颜色单独表意 */
.banner {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-4);
  background: var(--warn-dim);
  border: 1px solid var(--warn);
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  color: var(--ink-2);
  line-height: 1.6;
}
.banner svg { flex: 0 0 auto; color: var(--warn); margin-top: 2px; }
.banner.err { background: var(--bad-dim); border-color: var(--bad); }
.banner.err svg { color: var(--bad); }

/* ─── 商品卡片 ────────────────────────────────────────────── */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(224px, 1fr));
  gap: var(--sp-4);
  margin-top: var(--sp-5);
}

.pcard {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.pcard:hover { border-color: var(--border-strong); transform: translateY(-1px); }

/* 图片区。约 81% 商品有可用外链图，其余走 .pcard-noimg 版式 */
.pcard-img {
  aspect-ratio: 4 / 3;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex: 0 0 auto;
}
.pcard-img img {
  width: 100%; height: 100%;
  object-fit: contain;
  display: block;
}

.pcard-body { padding: var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-2); flex: 1 1 auto; }

.pcard-top { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }

.pcard-brand {
  font-size: var(--fs-xs);
  color: var(--accent-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 0 var(--sp-2);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pcard-cat { font-size: var(--fs-xs); color: var(--ink-4); }

.pcard-name {
  font-size: var(--fs-sm);
  line-height: 1.5;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.pcard-foot {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-top: auto;
  padding-top: var(--sp-2);
}

/* 价格是卡片里最大的数字，但不是 hero，仍可用 tabular 对齐网格内多张卡片 */
.pcard-price {
  font-size: var(--fs-lg);
  font-weight: 600;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.pcard-price.na {
  font-size: var(--fs-sm);
  font-weight: 400;
  color: var(--ink-4);
}

.pcard-code {
  font-family: var(--mono);
  font-size: var(--fs-xs);
  color: var(--ink-4);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 50%;
}

/* ─── 输入区 ──────────────────────────────────────────────── */
.composer {
  flex: 0 0 auto;
  padding: var(--sp-4) var(--sp-7) var(--sp-5);
  background: linear-gradient(to top, var(--bg) 60%, transparent);
}

.composer-box {
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: var(--sp-3);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  padding: var(--sp-3) var(--sp-3) var(--sp-3) var(--sp-5);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.composer-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-wash);
}

#q {
  flex: 1 1 auto;
  background: none;
  border: none;
  outline: none;
  resize: none;
  line-height: 1.6;
  padding: var(--sp-2) 0;
  max-height: 160px;
  overflow-y: auto;
}
#q::placeholder { color: var(--ink-4); }

.send {
  flex: 0 0 auto;
  width: 32px; height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: opacity var(--dur) var(--ease), transform var(--dur-fast) var(--ease);
}
.send:hover:not(:disabled) { transform: scale(1.05); }
.send:disabled { opacity: 0.35; cursor: default; }

.composer-note {
  max-width: 860px;
  margin: var(--sp-3) auto 0;
  font-size: var(--fs-xs);
  color: var(--ink-4);
  text-align: center;
}

/* ─── 右栏：数据面板 ──────────────────────────────────────── */
.panel {
  position: relative;
  width: 0;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-left: 1px solid transparent;
  overflow: hidden;
  transition: width var(--dur-slow) var(--ease);
  min-height: 0;
}
.panel.open {
  width: var(--panel-w);
  border-left-color: var(--border);
}
/* 拖拽中禁用过渡，否则跟手感很差 */
.panel.dragging { transition: none; }

.panel-grip {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 5px;
  cursor: col-resize;
  z-index: 2;
}
.panel-grip:hover, .panel-grip.active { background: var(--accent); }

.panel-head {
  flex: 0 0 auto;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--sp-4) 0 var(--sp-5);
  border-bottom: 1px solid var(--border);
}

.panel-title {
  font-size: var(--fs-sm);
  color: var(--ink-2);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.iconbtn {
  width: 26px; height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: var(--r-sm);
  color: var(--ink-3);
  cursor: pointer;
  flex: 0 0 auto;
}
.iconbtn:hover { background: var(--surface-2); color: var(--ink); }

.panel-body {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--sp-5);
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
}

/* 窄屏时面板改为覆盖层，避免把对话挤没 */
@media (max-width: 1280px) {
  .panel.open {
    position: fixed;
    top: var(--topbar-h);
    right: 0;
    bottom: 0;
    z-index: 40;
    box-shadow: var(--shadow-3);
  }
}

/* ─── 指标卡（single）───────────────────────────────────────
 * 大数字用比例数字，不用 tabular-nums —— 等宽数字在大字号下会显得松散。
 */
.metric {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-6);
}

.metric-label {
  font-size: var(--fs-sm);
  color: var(--ink-3);
  margin-bottom: var(--sp-3);
}

.metric-value {
  font-size: var(--fs-hero);
  font-weight: 600;
  line-height: 1.15;
  color: var(--accent);
  letter-spacing: -0.02em;
  word-break: break-all;
}

.metric-raw {
  margin-top: var(--sp-3);
  font-size: var(--fs-xs);
  color: var(--ink-4);
  font-family: var(--mono);
}

/* ─── 图表块 ──────────────────────────────────────────────── */
.block {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}

.block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
}

.block-title { font-size: var(--fs-sm); color: var(--ink-2); font-weight: 600; }
.block-sub { font-size: var(--fs-xs); color: var(--ink-4); font-variant-numeric: tabular-nums; }

.block-actions { display: flex; gap: var(--sp-2); }

.minibtn {
  font-size: var(--fs-xs);
  padding: 2px var(--sp-3);
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  color: var(--ink-3);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--dur-fast) var(--ease);
}
.minibtn:hover { color: var(--accent); border-color: var(--accent); }
.minibtn.done { color: var(--good); border-color: var(--good); }

.chart-wrap { padding: var(--sp-4); }

/* SVG 图表内的文字一律走文字令牌，绝不穿数据色 */
.chart text { fill: var(--ink-3); font-size: 11px; }
.chart .val { fill: var(--ink); font-variant-numeric: tabular-nums; }
.chart .lbl { fill: var(--ink-2); }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; }
.chart .axis-line { stroke: var(--axis); stroke-width: 1; }
.chart .bar { fill: var(--accent); }
.chart .bar-track { fill: var(--track); }
.chart .bar-hit { fill: transparent; cursor: default; }
.chart .row:hover .bar { fill: var(--accent-2); }
.chart .row:hover .bar-track { fill: var(--surface-3); }

.empty {
  padding: var(--sp-7) var(--sp-5);
  text-align: center;
  color: var(--ink-4);
  font-size: var(--fs-sm);
}

/* 交叉验算通过：低调一行，是信任这个数的依据。不一致时走 .banner 告警。 */
.verify-ok {
  margin-bottom: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-left: 2px solid var(--good);
  background: var(--good-dim);
  border-radius: var(--r-sm);
  font-size: var(--fs-xs);
  color: var(--ink-3);
  line-height: 1.5;
}

/* 还在验算：中性色，不能用绿色 —— 绿色会被读成「已经验过了，没问题」。 */
.verify-ok.pending {
  border-left-color: var(--ink-4);
  background: var(--surface-2);
  color: var(--ink-4);
}

/* ─── 表格 ────────────────────────────────────────────────── */
.tablewrap { overflow: auto; max-height: 460px; }

table.data {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  font-size: var(--fs-sm);
}

table.data th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-3);
  color: var(--ink-2);
  font-weight: 600;
  text-align: left;
  padding: var(--sp-3) var(--sp-4);
  white-space: nowrap;
  border-bottom: 1px solid var(--border-strong);
  cursor: pointer;
  user-select: none;
}
table.data th:hover { color: var(--accent); }

table.data th .sort {
  display: inline-block;
  width: 10px;
  margin-left: var(--sp-2);
  color: var(--ink-4);
  font-size: 9px;
}
table.data th[aria-sort] .sort { color: var(--accent); }

table.data td {
  padding: var(--sp-2) var(--sp-4);
  border-bottom: 1px solid var(--border);
  color: var(--ink-2);
  white-space: nowrap;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 数字列右对齐 + 等宽，这是 tabular-nums 该用的地方 */
table.data td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

table.data tbody tr:hover td { background: var(--surface-3); color: var(--ink); }
table.data tbody tr:last-child td { border-bottom: none; }

.table-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--border);
  font-size: var(--fs-xs);
  color: var(--ink-4);
}

/* ─── SQL ─────────────────────────────────────────────────── */
.sqlbox { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-lg); }

.sqlbox summary {
  padding: var(--sp-3) var(--sp-4);
  cursor: pointer;
  font-size: var(--fs-sm);
  color: var(--ink-3);
  user-select: none;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  list-style: none;
}
.sqlbox summary::-webkit-details-marker { display: none; }
.sqlbox summary:hover { color: var(--ink); }
.sqlbox summary .caret-i { color: var(--ink-4); transition: transform var(--dur) var(--ease); }
.sqlbox[open] summary .caret-i { transform: rotate(90deg); }

.sql-explain {
  padding: 0 var(--sp-4) var(--sp-3);
  font-size: var(--fs-xs);
  color: var(--ink-3);
  line-height: 1.6;
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--sp-3);
}

.sql-body { padding: 0 var(--sp-4) var(--sp-4); }

pre.sql {
  margin: 0;
  padding: var(--sp-4);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-family: var(--mono);
  font-size: var(--fs-xs);
  line-height: 1.7;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--ink-2);
}
/* SQL 语法高亮 */
pre.sql .k { color: var(--accent); font-weight: 600; }  /* 关键字 */
pre.sql .f { color: var(--accent-2); }                  /* 函数 */
pre.sql .s { color: var(--good); }                      /* 字符串 */
pre.sql .n { color: var(--warn); }                      /* 数字 */
pre.sql .c { color: var(--ink-4); font-style: italic; } /* 注释 */

.sql-actions { display: flex; gap: var(--sp-2); margin-top: var(--sp-3); }

/* ─── 屏幕阅读器专用 ──────────────────────────────────────── */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
