/* 控制台样式。
 *
 * 刻意复用 style.css 的全部 token（颜色/字体/圆角），只加布局与控制台特有的组件——
 * 控制台和官网是同一个产品，换一套视觉语言只会让人觉得跳到了别的站。
 *
 * 与营销页的区别不在配色，在信息密度：
 *   - 没有 hero，第一屏就是数据
 *   - 数字一律 tabular-nums 等宽，成列时能对齐比较
 *   - 语义色只用于状态（额度告急、风险等级），强调色只留给操作
 */

/* 控制台比营销页宽——数据面需要横向空间。但**页头必须跟着一起宽**，
   否则 logo/导航停在 960，下面的卡片铺到 1180，两者差 220px、左右各支出去 110px，
   看着就像没排过版。console.css 只在控制台页加载，这个覆盖不会波及其他页面。 */
.container { max-width: 1180px; }

.console {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 20px 64px;
  display: grid;
  grid-template-columns: 168px minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}

/* ---- 侧栏 ---- */
.side { position: sticky; top: 20px; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-item {
  text-align: left; padding: 9px 12px; border: none; border-radius: 9px;
  background: none; color: var(--text-dim); font: inherit; font-size: 14px; cursor: pointer;
}
.side-item:hover { background: var(--bg-card); color: var(--text); }
.side-item.on {
  background: var(--bg-card); color: var(--text); font-weight: 600;
  box-shadow: inset 2px 0 0 var(--accent);
}

/* ---- 面板 ---- */
.main { min-width: 0; }
.panel-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.panel-head h1 { margin: 0; font-size: 22px; }
.panel-sub { font-size: 13px; color: var(--text-dim); }

.card {
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: 14px; padding: 18px 20px; margin-bottom: 16px;
}
.card-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.card-head h2 { margin: 0; font-size: 15px; }
.card-sub { font-size: 12.5px; color: var(--text-faint); }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.two-col .card { margin-bottom: 0; }

/* ---- 指标卡 ---- */
.metric-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 16px; }
.metric {
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: 14px; padding: 16px 18px;
}
.metric-label { font-size: 12.5px; color: var(--text-dim); margin-bottom: 8px; }
.metric-value {
  font-size: 26px; font-weight: 700; line-height: 1.1;
  font-variant-numeric: tabular-nums; letter-spacing: -0.02em;
}
.metric-of { font-size: 15px; font-weight: 400; color: var(--text-faint); margin-left: 3px; }
.metric-foot { margin-top: 8px; font-size: 12px; color: var(--text-faint); }
.metric-foot a { color: var(--accent); }
.bar { height: 5px; border-radius: 3px; background: var(--line); margin-top: 10px; overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: var(--accent); border-radius: 3px; }
/* 额度告急才变色。平时保持中性——到处都是彩色的话，真正告急时反而看不见 */
.bar-fill.warn { background: var(--medium); }
.bar-fill.crit { background: var(--critical); }

/* ---- 用量柱状图（纯 CSS，无图表库）---- */
.chart { display: flex; align-items: flex-end; gap: 4px; height: 132px; }
/* 空态不占满图表高度：一行字撑出 130px 空白，看着像加载失败 */
.chart.is-empty { height: auto; display: block; }
.chart-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; min-width: 0; }
.chart-bar {
  background: color-mix(in srgb, var(--accent) 78%, transparent);
  border-radius: 3px 3px 0 0; min-height: 2px;
}
/* 零值也要占一格浅底：留白会让人以为那天没数据，而不是"那天是 0" */
.chart-col.zero .chart-bar { background: var(--line); }
.chart-col:hover .chart-bar { background: var(--accent); }
.chart-x { margin-top: 6px; font-size: 10px; color: var(--text-faint); text-align: center;
           white-space: nowrap; overflow: hidden; }
.chart-empty { color: var(--text-faint); font-size: 13px; padding: 34px 0; text-align: center; }

/* ---- 开始使用（空账户引导）---- */
.start-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.start-item {
  display: flex; flex-direction: column; gap: 6px; text-align: left;
  padding: 15px 16px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--bg); color: inherit; font: inherit; cursor: pointer;
}
.start-item:hover { border-color: var(--accent); background: var(--bg-card); }
.start-title { font-size: 15px; font-weight: 600; }
.start-desc { font-size: 13px; line-height: 1.65; color: var(--text-dim); }
/* 动作提示锚到底：两块文案长短不一，不锚底箭头会错位 */
.start-go { margin-top: auto; padding-top: 6px; font-size: 13px; color: var(--accent); }

/* ---- 查询 ---- */
.q-form { display: flex; gap: 8px; }
.q-form input {
  flex: 1; min-width: 0; padding: 10px 13px; font-size: 15px;
  border: 1.5px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--text); font-family: var(--font-mono);
}
.q-form input:focus { outline: none; border-color: var(--accent); }
.q-form .btn-submit { width: auto; flex: none; margin-top: 0; padding: 10px 22px; }
.q-hint { margin-top: 10px; font-size: 13px; }
.linkish { border: none; background: none; padding: 0; font: inherit; font-size: 13px;
           color: var(--accent); cursor: pointer; }
.q-alert {
  margin-top: 12px; padding: 9px 12px; border-radius: 9px; font-size: 13px;
  background: color-mix(in srgb, var(--critical) 12%, var(--bg-card));
  border: 1px solid color-mix(in srgb, var(--critical) 35%, transparent);
}

.res-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.res-ip { font-size: 19px; font-weight: 600; }
.res-geo { margin-top: 4px; font-size: 13px; color: var(--text-dim); }
.res-score { text-align: right; white-space: nowrap; }
.res-num { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums;
           color: var(--level-color, var(--text)); }
.res-level { display: block; font-size: 12.5px; color: var(--level-color, var(--text-dim)); }
.res-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.res-tags:empty { display: none; }
.rtag {
  font-size: 12px; padding: 3px 9px; border-radius: 999px;
  background: color-mix(in srgb, var(--level-color, var(--text-dim)) 12%, var(--bg-card));
  border: 1px solid color-mix(in srgb, var(--level-color, var(--text-dim)) 30%, transparent);
}
.rtag small { color: var(--text-faint); font-variant-numeric: tabular-nums; }

.tagline { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.tagline-tag { font-size: 14px; font-weight: 700; color: var(--pulse-color); }
.tagline-why { font-size: 13px; color: var(--text-dim); }
.ev { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-size: 13px;
      border-top: 1px solid var(--line); }
.ev-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint); flex: none; }
.ev-dot.fresh { background: var(--critical); }
.ev-dot.aging { background: var(--medium); }
.ev-cal { margin-left: auto; font-size: 11.5px; color: var(--ok); }
.ev-cal.no { color: var(--text-faint); }

/* ---- 表格 / 键值 ---- */
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl td { padding: 6px 0; border-top: 1px solid var(--line); }
.tbl tr:first-child td { border-top: none; }
.tbl .thead-row td { font-size: 12px; color: var(--text-faint); padding-bottom: 8px; }
.tbl td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .hit td:last-child { color: var(--critical); font-weight: 600; }
.tbl .miss td { color: var(--text-faint); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 7px 16px; margin: 0; font-size: 13.5px; }
.kv dt { color: var(--text-dim); }
.kv dd { margin: 0; text-align: right; }

/* ---- Key 列表 ---- */
.krow { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line);
        flex-wrap: wrap; }
.krow:first-child { border-top: none; }
.krow-main { min-width: 0; flex: 1; }
.krow-pfx { font-family: var(--font-mono); font-size: 13.5px; }
.krow-meta { font-size: 12px; color: var(--text-faint); margin-top: 2px; }
.krow-use { font-size: 12.5px; color: var(--text-dim); font-variant-numeric: tabular-nums;
            white-space: nowrap; }
.btn-mini {
  flex: none; padding: 5px 11px; font: inherit; font-size: 12.5px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text-dim);
}
.btn-mini:hover { border-color: var(--critical); color: var(--critical); }
.reveal {
  margin-top: 14px; padding: 12px 14px; border-radius: 10px;
  background: color-mix(in srgb, var(--medium) 10%, var(--bg-card));
  border: 1px solid color-mix(in srgb, var(--medium) 35%, transparent);
}
.reveal b { display: block; margin-bottom: 7px; font-size: 13px; }
.reveal code { font-family: var(--font-mono); font-size: 13px; word-break: break-all; }
.code {
  margin: 0; padding: 13px 15px; border-radius: 10px; overflow-x: auto;
  background: #0f172a; color: #e2e8f0; font-family: var(--font-mono); font-size: 12.5px;
  line-height: 1.65;
}
.dim { color: var(--text-faint); font-size: 13.5px; }

/* ---- 状态徽标 ---- */
.pill { display: inline-block; font-size: 12px; padding: 2px 9px; border-radius: 999px;
        border: 1px solid var(--line); color: var(--text-dim); }
.pill.new { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.pill.done { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }

/* ---- 未登录闸门 ---- */
.console-gate { display: grid; place-items: center; padding: 90px 20px; }
.gate-box { max-width: 380px; width: 100%; text-align: center;
            background: var(--bg-card); border: 1px solid var(--line);
            border-radius: 16px; padding: 34px 28px; }
.gate-box h1 { margin: 0 0 8px; font-size: 21px; }
.gate-box p { margin: 0 0 22px; font-size: 14px; color: var(--text-dim); line-height: 1.7; }

/* ---- 窄屏：侧栏变成横向标签条 ---- */
@media (max-width: 820px) {
  .console { grid-template-columns: 1fr; gap: 16px; padding-top: 16px; }
  .side { position: static; }
  .side-nav {
    flex-direction: row; gap: 6px; overflow-x: auto; padding-bottom: 4px;
    /* 标签条本身横向滚动，不能让整页跟着横向滚 */
    scrollbar-width: none;
  }
  .side-nav::-webkit-scrollbar { display: none; }
  .side-item { white-space: nowrap; border: 1px solid var(--line); }
  .side-item.on { box-shadow: none; border-color: var(--accent); color: var(--accent); }
  .res-head { flex-direction: column; }
  .res-score { text-align: left; }
}

/* 更窄时 Key 行改为堆叠：一行里塞前缀+备注+速率+创建日期+用量+按钮，
   在 375px 上备注会被挤成三行，而右侧的用量和按钮却孤零零吊着。 */
@media (max-width: 560px) {
  .krow-main { flex: 1 1 100%; }
  .krow-use { margin-right: auto; }
}

/* ---- 深色 ---- */
@media (prefers-color-scheme: dark) {
  .code { background: #0b1220; }
}

/* ---- 产品面板 ---- */
.pv-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; margin-top: 16px; }
.pv { padding: 13px 14px; border: 1px solid var(--line); border-radius: 11px; background: var(--bg); }
.pv-t { font-size: 13.5px; font-weight: 600; margin-bottom: 5px; }
.pv-d { font-size: 12.5px; line-height: 1.7; color: var(--text-dim); }

/* 部署步骤条。product.css 里有一份同名的，但那个文件只在产品页加载——
   控制台不引它，所以这里必须自带。两处样式若要改，记得一起改。 */
.steps { counter-reset: s; list-style: none; margin: 0; padding: 0; }
.steps li {
  counter-increment: s; position: relative;
  padding: 0 0 16px 38px; border-left: 2px solid var(--line); margin-left: 12px;
}
.steps li:last-child { border-left-color: transparent; padding-bottom: 0; }
.steps li::before {
  content: counter(s); position: absolute; left: -13px; top: -2px;
  width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--bg-card); border: 1.5px solid var(--line);
  font-size: 12px; font-weight: 600; color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.steps b { display: block; font-size: 14px; margin-bottom: 4px; }
.steps p { margin: 0; font-size: 13px; line-height: 1.7; color: var(--text-dim); }

/* 0 分时的语义说明，与首页 .level-note 同一意图：排在徽标与标签之间，
   读者视线从「0」下来先撞上这句话，再看到标签，才不会把 0 读成「安全」 */
.res-note{margin:6px 0 8px;max-width:42em;font-size:12.5px;line-height:1.65;color:var(--text-dim)}

/* ---- 额度横幅 / 申请提升额度 ----
   ≥80% 才出现，100% 变红。平时不占位：一直挂着的提示没人看。 */
.quota-banner {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 16px; padding: 11px 14px; border-radius: 11px; font-size: 13.5px;
  background: color-mix(in srgb, var(--medium) 10%, var(--bg-card));
  border: 1px solid color-mix(in srgb, var(--medium) 40%, transparent);
}
.quota-banner.full {
  background: color-mix(in srgb, var(--critical) 9%, var(--bg-card));
  border-color: color-mix(in srgb, var(--critical) 45%, transparent);
}
.quota-banner .btn-mini { margin-left: auto; }
.quota-ask .qa-note {
  width: 100%; box-sizing: border-box; margin-top: 8px; padding: 9px 12px; font: inherit; font-size: 13.5px;
  border: 1.5px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text);
}
.quota-ask .qa-note:focus { outline: none; border-color: var(--accent); }
.quota-ask .q-form input { font-family: inherit; }

/* ---- 范围切换 ---- */
.rng-bar { margin-left: auto; display: inline-flex; gap: 4px; }
.rng {
  padding: 4px 11px; font: inherit; font-size: 12.5px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 999px; background: var(--bg); color: var(--text-dim);
}
.rng.on { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.since-note { font-size: 12.5px; color: var(--text-faint); margin: -8px 0 12px; }

/* ---- 空态卡：一句话 + 一个动作，不占满高度 ---- */
.empty-card { color: var(--text-dim); font-size: 13.5px; line-height: 1.7; }
.empty-card .linkish { font-size: 13.5px; }

/* ---- 分布条 ---- */
.dist { display: flex; flex-direction: column; gap: 7px; }
.dist-row { display: grid; grid-template-columns: 92px minmax(0, 1fr) 64px 44px; align-items: center; gap: 10px;
            font-size: 13px; }
.dist-row.zero { color: var(--text-faint); }
.dist-label { color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dist-label.wide { grid-column: 1 / 3; }
.dist-track { display: block; height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.dist-fill { display: block; height: 100%; border-radius: 4px;
             background: color-mix(in srgb, var(--accent) 78%, transparent); }
.dist-n, .dist-pct { text-align: right; font-variant-numeric: tabular-nums; }
.dist-pct { color: var(--text-faint); font-size: 12px; }

/* ---- 实时图：有错误的分钟换色，图例说明 ---- */
.chart-col.has-e4 .chart-bar { background: color-mix(in srgb, var(--medium) 70%, transparent); }
.chart-col.has-e429 .chart-bar { background: var(--medium); }
.chart-col.has-e5 .chart-bar { background: var(--critical); }
.chart-legend { display: flex; gap: 14px; margin-top: 10px; font-size: 12px; color: var(--text-faint); }
.lg::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px;
              vertical-align: -1px; background: color-mix(in srgb, var(--accent) 78%, transparent); }
.lg.e4::before { background: color-mix(in srgb, var(--medium) 70%, transparent); }
.lg.e429::before { background: var(--medium); }
.lg.e5::before { background: var(--critical); }
/* 60 根柱子挤在一起时 gap 收小，否则窄屏上一半宽度都是缝 */
#rt-chart { gap: 2px; }

/* ---- 表格：渠道榜 / 账本 ---- */
.tbl-wrap { overflow-x: auto; }
.src-tbl td, .ledger td { white-space: nowrap; }
.src-tbl td:last-child, .ledger td:last-child { text-align: left; font-weight: 400; }
.src-tbl .num, .ledger .num { text-align: right; font-variant-numeric: tabular-nums; }
.ledger .num.over { color: var(--medium); font-weight: 600; }
.src-tbl .share { min-width: 140px; }
.src-tbl .share .dist-track { display: inline-block; width: 80px; vertical-align: middle; margin-right: 8px; }
.src-tbl .rts .rtag { font-size: 11.5px; padding: 1px 7px; margin-right: 4px; }
.src-tbl .spark { display: flex; align-items: flex-end; gap: 2px; height: 22px; min-width: 60px; }
.spark-bar { display: inline-block; width: 6px; border-radius: 1px 1px 0 0;
             background: color-mix(in srgb, var(--accent) 78%, transparent); }
.spark-bar.zero { background: var(--line); }
.pill.warn { color: var(--medium); border-color: color-mix(in srgb, var(--medium) 45%, transparent); margin-left: 6px; }
.bl-export { margin-left: auto; text-decoration: none; }
.bl-foot { margin: 12px 0 0; font-size: 12.5px; }

@media (max-width: 560px) {
  .dist-row { grid-template-columns: 76px minmax(0, 1fr) 56px 40px; gap: 6px; }
  .rng-bar { margin-left: 0; }
}

/* ---- 逐日走势（堆叠柱）与指标变化 ---- */
.stack { display: flex; align-items: flex-end; gap: 4px; height: 150px; }
.stack-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; min-width: 0; }
.stack-bar { display: flex; flex-direction: column; justify-content: flex-end; border-radius: 3px 3px 0 0; overflow: hidden; min-height: 2px; background: var(--line); }
.stack-seg { display: block; width: 100%; }
.stack-seg.s3 { background: var(--critical); }
.stack-seg.s2 { background: var(--medium); }
.stack-seg.s1 { background: color-mix(in srgb, var(--accent) 78%, transparent); }
.stack-seg.s0 { background: color-mix(in srgb, var(--accent) 30%, transparent); }
.stack-seg.none { background: var(--line); }
.stack-col.today .stack-bar { outline: 2px solid var(--accent); outline-offset: 1px; }
.stack-col.zero .stack-bar { background: var(--line); }
.lg.s3::before { background: var(--critical); }
.lg.s2::before { background: var(--medium); }
.lg.s1::before { background: color-mix(in srgb, var(--accent) 78%, transparent); }
.lg.s0::before { background: color-mix(in srgb, var(--accent) 30%, transparent); }
.lg.none::before { background: var(--line); }
.delta { margin-top: 6px; font-size: 12px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.delta.good { color: var(--ok, #1a7f5a); }
.delta.bad { color: var(--critical); }
.keysel { font: inherit; font-size: 12.5px; color: var(--text-dim); background: var(--bg-card); border: 1px solid var(--line); border-radius: 8px; padding: 3px 8px; }

/* ---- 查询分析：活的 QPS 徽标 / 服务状态行 / 走势错误标记 ---- */
.pill.live { color: var(--text-faint); border-color: var(--line); font-variant-numeric: tabular-nums; }
.pill.live.on { color: var(--ok, #1a7f5a); border-color: color-mix(in srgb, var(--ok, #1a7f5a) 45%, transparent); }
.health-row { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-top: 14px; padding: 12px 16px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--bg-card); font-size: 13px; color: var(--text-dim); }
.health-row b { font-weight: 500; color: var(--text-faint); }
.stack-col.has-err .chart-x::before { content: "•"; color: var(--critical); margin-right: 2px; }
.linkish { background: none; border: none; color: var(--accent); font: inherit; cursor: pointer; padding: 0; }
.two-col .card.wide { grid-column: 1 / -1; }
