/* ============================================================
   投放效果看板 — 浅色设计系统
   结构：01 预算/消耗/消耗比 → 02 回收（vs 50%）→ 03 核心问题 → 04 三层趋势
   ============================================================ */

:root {
  --fs-scale: 1.15; /* 全局字号放大档位 */
  --bg: #f4f6fa;
  --card: #ffffff;
  --line: #e3e8ef;
  --line-soft: #eef1f6;
  --ink: #0f1728;
  --ink-2: #475467;
  --ink-3: #8b95a7;
  --ink-4: #aab3c2;

  --blue: #2563eb;
  --blue-ink: #1d4ed8;
  --blue-bg: #eef4ff;

  --green: #059669;
  --green-bg: #ecfdf3;
  --amber: #a16207;
  --amber-bg: #fef9c3;
  --red: #dc2626;
  --red-bg: #fee2e2;

  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04);
  --num: "SF Mono", ui-monospace, "Menlo", monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  font-size: calc(13px * var(--fs-scale));
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  max-width: 100%;
  overflow-x: hidden; /* 防下钻表等宽内容把整页撑出视口 */
}

h1, h2, h3, p { margin: 0; }
button { font-family: inherit; }
svg { display: block; }

/* ---------------- top bar ---------------- */

.top {
  position: sticky; top: 0; z-index: 30;
  background: rgba(255, 255, 255, .9);
  backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid var(--line);
}

.top-inner {
  max-width: 1560px; margin: 0 auto;
  padding: 12px 24px 10px;
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 10px; }
.mark { width: 30px; height: 30px; color: var(--blue); flex: none; }
.mark svg { width: 30px; height: 30px; }
.brand h1 { font-size: calc(15px * var(--fs-scale)); font-weight: 650; letter-spacing: -.01em; }
.brand p { font-size: calc(11px * var(--fs-scale)); color: var(--ink-3); }

.controls { display: flex; align-items: center; gap: 8px; margin-left: auto; flex-wrap: wrap; }

.seg {
  display: inline-flex; padding: 2px; gap: 2px;
  background: #eff2f7; border-radius: 9px;
}
.seg button {
  border: 0; background: transparent; cursor: pointer;
  padding: 5px 11px; border-radius: 7px;
  font-size: calc(12px * var(--fs-scale)); font-weight: 520; color: var(--ink-2);
  transition: background .15s, color .15s, box-shadow .15s;
  white-space: nowrap;
}
.seg button:hover { color: var(--ink); }
.seg button.is-active {
  background: #fff; color: var(--ink); font-weight: 600;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .1);
}
.seg button:disabled { cursor: not-allowed; opacity: .45; color: var(--ink-3, #98a2b3); }
.seg button:disabled:hover { color: var(--ink-3, #98a2b3); }

.btn, .btn-ghost {
  display: inline-flex; align-items: center; gap: 5px;
  border-radius: 9px; padding: 6px 12px; cursor: pointer;
  font-size: calc(12px * var(--fs-scale)); font-weight: 550; white-space: nowrap;
  transition: all .15s;
}
.btn { background: var(--blue); border: 1px solid var(--blue); color: #fff; }
.btn:hover { background: var(--blue-ink); border-color: var(--blue-ink); }
.btn svg, .btn-ghost svg { width: 14px; height: 14px; }
.btn-ghost { background: #fff; border: 1px solid var(--line); color: var(--ink-2); }
.btn-ghost:hover { border-color: #cfd6e2; color: var(--ink); }

/* 数据说明条：更新时间和口径放在页面最顶上 */
.meta-bar {
  background: #f8fafd;
  border-bottom: 1px solid var(--line-soft);
}
.top-meta {
  max-width: 1560px; margin: 0 auto;
  padding: 4px 24px 5px;
  display: flex; align-items: center; gap: 7px;
  font-size: calc(11px * var(--fs-scale)); color: var(--ink-3);
  min-height: 26px;
}
.top-meta b {
  color: var(--ink-2); font-weight: 560;
  font-variant-numeric: tabular-nums;
}
.meta-link {
  border: 0; background: transparent; cursor: pointer;
  padding: 0 0 0 12px; margin-left: 2px;
  font-size: calc(11px * var(--fs-scale)); font-weight: 560; color: var(--blue);
  text-decoration: underline; text-underline-offset: 3px;
  text-decoration-thickness: 1px; text-decoration-color: #c7d9fe;
}
.meta-link:hover { text-decoration-color: var(--blue); }
.meta-btn {
  border: 1px solid #c7d9fe; background: #fff; cursor: pointer;
  padding: 2px 10px; margin-left: 4px; border-radius: 6px;
  font-size: calc(11px * var(--fs-scale)); font-weight: 600; color: var(--blue);
  line-height: 1.4;
}
.meta-btn:hover { background: var(--blue-bg); border-color: var(--blue); }
.meta-btn:disabled, .meta-btn.is-busy {
  opacity: 0.65; cursor: wait;
}
.top-meta .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--green); box-shadow: 0 0 0 3px var(--green-bg);
}
.top-meta .sep { color: var(--ink-4); }
.top-meta .grow { flex: 1; }
.top-meta .hint {
  font-size: calc(11px * var(--fs-scale)); color: var(--blue-ink);
  background: var(--blue-bg); padding: 2px 8px; border-radius: 6px;
  font-weight: 550;
}
.top-meta .acct {
  font-size: calc(11px * var(--fs-scale)); font-weight: 600; color: var(--ink-2);
  background: #f2f4f8; padding: 2px 8px; border-radius: 6px;
}

/* ---------------- main / sections ---------------- */

main {
  max-width: 1560px; margin: 0 auto;
  padding: 18px 24px 32px;
  display: flex; flex-direction: column; gap: 20px;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.sect { display: flex; flex-direction: column; gap: 10px; }

.sec { display: flex; align-items: baseline; gap: 9px; padding: 0 2px; }
.sec .no {
  font-size: calc(10px * var(--fs-scale)); font-weight: 700; color: var(--blue);
  letter-spacing: .08em; font-variant-numeric: tabular-nums;
  background: var(--blue-bg); border-radius: 5px; padding: 1px 5px;
  transform: translateY(-1px);
}
.sec h2 { font-size: calc(13.5px * var(--fs-scale)); font-weight: 650; letter-spacing: -.01em; }
.sec .desc { font-size: calc(11.5px * var(--fs-scale)); color: var(--ink-3); }
.sec .right {
  margin-left: auto; font-size: calc(11.5px * var(--fs-scale)); color: var(--ink-2);
  font-variant-numeric: tabular-nums; display: flex; align-items: center; gap: 8px;
}

.sect, .card, #drillBody {
  max-width: 100%;
  min-width: 0;
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px 10px;
  border-bottom: 1px solid var(--line-soft);
}
.card-head h2 { font-size: calc(13px * var(--fs-scale)); font-weight: 600; letter-spacing: -.005em; }
.card-head .sub { font-size: calc(11.5px * var(--fs-scale)); color: var(--ink-3); font-weight: 450; margin-left: 2px; }
.card-head .head-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.tag {
  font-size: calc(10.5px * var(--fs-scale)); font-weight: 550;
  padding: 2px 7px; border-radius: 6px;
  background: #f2f4f8; color: var(--ink-2);
}
.tag.live { background: var(--blue-bg); color: var(--blue-ink); }
.tag.name { background: #eef1f6; color: var(--ink); font-weight: 650; }

/* ---------------- row layouts ---------------- */

.row-bud {
  display: grid;
  grid-template-columns: minmax(0, .78fr) minmax(0, 1.72fr);
  gap: 12px;
}
.row-mini {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

/* ---------------- 代理名 ---------------- */

.who {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px 4px 8px;
  border: 1px solid var(--line); border-radius: 9px;
  background: #fff; white-space: nowrap;
}
.who .who-lb {
  font-size: calc(10px * var(--fs-scale)); font-weight: 600; letter-spacing: .04em;
  color: var(--ink-3); background: #f2f4f8;
  padding: 1px 5px; border-radius: 4px;
}
.who b { font-size: calc(12.5px * var(--fs-scale)); font-weight: 650; letter-spacing: -.01em; }
.who .who-tag {
  font-size: calc(9.5px * var(--fs-scale)); font-weight: 600; color: var(--blue-ink);
  background: var(--blue-bg); padding: 1px 5px; border-radius: 4px;
}
.who.is-ag { border-color: #cfdcf8; box-shadow: 0 0 0 3px rgba(37, 99, 235, .05); }
.who.is-ag b { font-size: calc(13.5px * var(--fs-scale)); }


/* ---------------- 预算卡 ---------------- */

.bud { padding: 0; display: flex; flex-direction: column; }
.bud-body { padding: 14px 16px 14px; display: flex; flex-direction: column; flex: 1; }

.bud-top { display: flex; align-items: baseline; gap: 8px; }
.bud-big {
  font-size: calc(26px * var(--fs-scale)); font-weight: 630; letter-spacing: -.03em;
  font-variant-numeric: tabular-nums; line-height: 1.15;
}
.bud-big small { font-size: calc(12px * var(--fs-scale)); font-weight: 450; color: var(--ink-3); letter-spacing: 0; margin-left: 3px; }
.bud-pct {
  margin-left: auto; font-size: calc(12px * var(--fs-scale)); font-weight: 650;
  font-variant-numeric: tabular-nums;
  padding: 2px 7px; border-radius: 6px;
  background: var(--blue-bg); color: var(--blue-ink);
}
.bud-pct.warn { background: var(--amber-bg); color: var(--amber); }
.bud-pct.over { background: var(--red-bg); color: var(--red); }

.bar {
  position: relative; height: 8px; border-radius: 5px;
  background: #eef1f6; margin-top: 11px; overflow: hidden;
}
.bar i {
  position: absolute; inset: 0 auto 0 0;
  border-radius: 5px; background: var(--blue);
  transition: width .7s cubic-bezier(.2, .8, .2, 1);
}
.bar i.warn { background: var(--amber); }
.bar i.over { background: var(--red); }

.bud-meta {
  display: flex; justify-content: space-between;
  font-size: calc(11px * var(--fs-scale)); color: var(--ink-3); margin-top: 6px;
}

.bud-accts { margin-top: auto; padding-top: 12px; display: flex; flex-direction: column; gap: 1px; }
.bud-acct {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 0; font-size: calc(11.5px * var(--fs-scale));
  border-top: 1px dashed var(--line-soft);
}
.bud-acct:first-child { border-top: 0; }
.bud-acct .nm { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.bud-acct .bud-bar { flex: 1; height: 3px; border-radius: 2px; background: #eef1f6; overflow: hidden; }
.bud-acct .bud-bar i { display: block; height: 100%; background: #c7d9fe; border-radius: 2px; }
.bud-acct b { font-weight: 600; font-variant-numeric: tabular-nums; min-width: 42px; text-align: right; }

/* 账户行：代号 + 产品·主投国家 + 预算 / 花费 */
.acc-row { padding: 7px 0 6px; border-top: 1px dashed var(--line-soft); }
.acc-row:first-child { border-top: 0; padding-top: 2px; }
.acc-top { display: flex; align-items: baseline; gap: 6px; }
.acc-nm {
  font-size: calc(11.5px * var(--fs-scale)); font-weight: 650; color: var(--ink);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.acc-nm em {
  font-style: normal; font-weight: 500; font-size: calc(10.5px * var(--fs-scale)); color: var(--ink-3);
  margin-left: 5px;
}
.acc-b {
  margin-left: auto; font-size: calc(11px * var(--fs-scale)); font-weight: 600;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.acc-b i { font-style: normal; font-weight: 450; color: var(--ink-3); }
.acc-b i.life { font-size: calc(9.5px * var(--fs-scale)); color: var(--ink-4); }
.acc-bar {
  display: block; height: 3px; border-radius: 2px;
  background: #eef1f6; overflow: hidden; margin-top: 5px;
}
.acc-bar i { display: block; height: 100%; background: var(--blue); border-radius: 2px; }
.acc-bar i.low { background: #f0c88a; }
.acc-bar i.over { background: var(--red); }


/* ---------------- 通用统计条 ---------------- */

.stats {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid var(--line-soft);
  margin-top: auto;
}
.stats > div { padding: 9px 14px 10px; }
.stats > div + div { border-left: 1px solid var(--line-soft); }
.stats span { display: block; font-size: calc(10.5px * var(--fs-scale)); color: var(--ink-3); margin-bottom: 1px; }
.stats b {
  font-size: calc(13px * var(--fs-scale)); font-weight: 600; font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
}
.stats b.mute { color: var(--ink-3); font-weight: 500; }

/* ---------------- 迷你图卡 ---------------- */

.mini { display: flex; flex-direction: column; }
.mini-head { padding: 12px 14px 0; }
.mini-head .title {
  font-size: calc(11.5px * var(--fs-scale)); color: var(--ink-2); font-weight: 550;
  display: flex; align-items: baseline; gap: 6px;
}
.mini-head .title em {
  font-style: normal; font-size: calc(10px * var(--fs-scale)); color: var(--ink-4); font-weight: 450;
}
.mini-head .val {
  font-size: calc(23px * var(--fs-scale)); font-weight: 630; letter-spacing: -.03em;
  font-variant-numeric: tabular-nums; line-height: 1.25; margin-top: 2px;
  display: flex; align-items: baseline; gap: 6px;
}
.mini-head .val .u { font-size: calc(11.5px * var(--fs-scale)); font-weight: 450; color: var(--ink-3); letter-spacing: 0; }
.mini-head .val .u.ok { color: var(--green); font-weight: 600; }
.mini-head .val .u.warn { color: var(--amber); font-weight: 600; }
.mini-head .val .u.bad { color: var(--red); font-weight: 600; }
.mini-head .val .u.mute { color: var(--ink-3); }
.mini-head .sub { font-size: calc(10.5px * var(--fs-scale)); color: var(--ink-3); margin-top: 1px; }

.chart-wrap { padding: 6px 8px 0; }
.chart-wrap svg { width: 100%; height: auto; }
.mini .chart-wrap { padding: 8px 6px 4px; }

.mini-foot {
  margin-top: auto; padding: 6px 14px 11px;
  font-size: calc(10.5px * var(--fs-scale)); color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  display: flex; gap: 8px; flex-wrap: wrap;
}
.mini-foot b { color: var(--ink-2); font-weight: 600; }

/* ---------------- 逐日明细 ---------------- */

.detail-head { cursor: pointer; }
.detail-head .toggle {
  margin-left: auto; font-size: calc(11.5px * var(--fs-scale)); color: var(--blue-ink);
  display: inline-flex; align-items: center; gap: 4px; font-weight: 550;
}
.detail-head .toggle svg { width: 13px; height: 13px; transition: transform .18s; }
.detail-head .toggle.open svg { transform: rotate(180deg); }

.queue-wrap {
  display: block;
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  max-width: 100%;
  min-width: 0;
}
table.q { width: 100%; border-collapse: collapse; font-size: calc(12.5px * var(--fs-scale)); }
table.q th, table.q td { padding: 8px 12px; text-align: right; white-space: nowrap; }
table.q th:first-child, table.q td:first-child { text-align: left; padding-left: 16px; }
table.q th:last-child, table.q td:last-child { padding-right: 16px; }
table.q thead th {
  font-size: calc(10.5px * var(--fs-scale)); font-weight: 550; color: var(--ink-3);
  border-bottom: 1px solid var(--line-soft);
  padding-top: 9px; padding-bottom: 7px;
  background: #fafbfd;
}
table.q thead tr.grp th { padding-bottom: 3px; font-size: calc(10px * var(--fs-scale)); letter-spacing: .04em; text-transform: uppercase; }
table.q td { border-bottom: 1px solid var(--line-soft); font-variant-numeric: tabular-nums; }
table.q tbody tr:last-child td { border-bottom: 0; }
table.q tbody tr:hover { background: #fafbfd; }
table.q .day { font-weight: 600; font-variant-numeric: tabular-nums; }
table.q .day small { color: var(--ink-3); font-weight: 450; margin-left: 5px; font-size: calc(10.5px * var(--fs-scale)); }
table.q .dim { color: var(--ink-3); }
table.q .col-spend { font-weight: 550; }
table.q tfoot td {
  border-top: 1px solid var(--line);
  background: #fafbfd; font-weight: 600;
  padding-top: 9px; padding-bottom: 9px;
}

.table-note {
  padding: 0 16px 11px; font-size: calc(10.5px * var(--fs-scale)); color: var(--ink-3);
}

/* ---------------- 核心问题 ---------------- */

.issue-list { display: flex; flex-direction: column; }
.issue {
  display: grid; grid-template-columns: 52px minmax(0, 1fr) 84px;
  gap: 14px; align-items: start;
  padding: 13px 16px;
}
.issue + .issue { border-top: 1px solid var(--line-soft); }
.issue .badge {
  font-size: calc(10.5px * var(--fs-scale)); font-weight: 600;
  padding: 2px 0; border-radius: 6px; text-align: center;
  background: #f2f4f8; color: var(--ink-2);
}
.issue.bad .badge { background: var(--red-bg); color: var(--red); }
.issue.warn .badge { background: var(--amber-bg); color: var(--amber); }
.issue.ok .badge { background: var(--green-bg); color: var(--green); }
.issue .tx b { font-size: calc(12.5px * var(--fs-scale)); font-weight: 600; display: block; letter-spacing: -.005em; }
.issue .tx p { font-size: calc(11.5px * var(--fs-scale)); color: var(--ink-2); margin-top: 3px; line-height: 1.65; }
.issue .mt {
  text-align: right; font-size: calc(13px * var(--fs-scale)); font-weight: 620;
  font-variant-numeric: tabular-nums; color: var(--ink);
}
.issue.bad .mt { color: var(--red); }
.issue.warn .mt { color: var(--amber); }
.issue.ok .mt { color: var(--green); }
.issue .mt small { display: block; font-size: calc(10px * var(--fs-scale)); font-weight: 450; color: var(--ink-3); }

/* ---------------- 三层趋势 ---------------- */

.drill-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px 10px; border-bottom: 1px solid var(--line-soft); }
.drill-head h2 { font-size: calc(13px * var(--fs-scale)); font-weight: 600; }
.drill-head .sub { font-size: calc(11.5px * var(--fs-scale)); color: var(--ink-3); }
.drill-head .head-right { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.search {
  display: flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: #fff;
  border-radius: 9px; padding: 4px 9px;
}
.search svg { width: 14px; height: 14px; color: var(--ink-4); flex: none; }
.search input {
  border: 0; outline: 0; background: transparent;
  font-size: calc(12px * var(--fs-scale)); width: 190px; color: var(--ink);
  font-family: inherit;
}
.search input::placeholder { color: var(--ink-4); }

.table-wrap {
  display: block;
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  max-width: 100%;
  min-width: 0;
}
table.d { width: 100%; border-collapse: collapse; font-size: calc(12.5px * var(--fs-scale)); }
table.d th, table.d td { padding: 8px 12px; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.d th:first-child, table.d td:first-child { text-align: left; padding-left: 16px; }
table.d th:nth-child(2), table.d td:nth-child(2) { text-align: left; }
table.d th:last-child, table.d td:last-child { padding-right: 16px; }
table.d thead th {
  font-size: calc(10.5px * var(--fs-scale)); font-weight: 550; color: var(--ink-3);
  background: #fafbfd; border-bottom: 1px solid var(--line-soft);
  padding-top: 7px; padding-bottom: 7px;
}
table.d thead tr.grp th { padding-bottom: 2px; font-size: calc(9.5px * var(--fs-scale)); letter-spacing: .05em; text-transform: uppercase; border-bottom: 0; }
table.d td { border-bottom: 1px solid var(--line-soft); }
table.d tbody tr:last-child td { border-bottom: 0; }
table.d tbody tr:hover { background: #fafbfd; }
table.d tbody tr.is-focus { background: var(--blue-bg); }
table.d .spark-cell { padding-top: 5px; padding-bottom: 5px; text-align: center; }
table.d tfoot td {
  border-top: 1px solid var(--line);
  background: #fafbfd; font-weight: 600;
}

.name-cell { display: flex; align-items: center; gap: 6px; max-width: 420px; cursor: pointer; }
.name-cell .caret {
  width: 15px; height: 15px; flex: none; border: 0; background: transparent;
  cursor: pointer; color: var(--ink-3); padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 4px;
}
.name-cell .caret:hover { background: #eef1f6; color: var(--ink); }
.name-cell .caret svg { width: 11px; height: 11px; transition: transform .18s; }
.name-cell .caret.open svg { transform: rotate(90deg); }
.name-cell .caret.blank { visibility: hidden; }
.name-cell .txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.name-cell .txt b { font-weight: 620; color: var(--ink); }

/* 灯 + 箭头 + 名字合成一格：缩进一次，三者一起右移，后面的数字列不动。
   表头是普通两列合并，固定在左边，不跟缩进跑。 */
table.d td.tree-cell { text-align: left; }
table.d td.tree-cell > .lamp { margin-right: 8px; vertical-align: middle; }
table.d td.tree-cell > .caret {
  width: 15px; height: 15px; flex: none; border: 0; background: transparent;
  cursor: pointer; color: var(--ink-3); padding: 0; margin-right: 3px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 4px; vertical-align: middle;
}
table.d td.tree-cell > .caret:hover { background: #eef1f6; color: var(--ink); }
table.d td.tree-cell > .caret svg { width: 11px; height: 11px; transition: transform .18s; }
table.d td.tree-cell > .caret.open svg { transform: rotate(90deg); }
table.d td.tree-cell > .caret.blank { visibility: hidden; }
table.d td.tree-cell > .txt { vertical-align: middle; }
tr.lv-agent .txt b { font-weight: 680; }
tr.lv-account .txt b { font-weight: 660; }
table.d.drill-t tbody#drillRows tr.lv-agent td { background: #f8fafc; }
tr.lv-adset .txt { color: var(--ink-2); }
tr.lv-ad .txt { color: var(--ink-3); font-size: calc(12px * var(--fs-scale)); }
tr.lv-adset .txt b, tr.lv-ad .txt b { color: var(--ink-2); font-weight: 600; }

.mini-bar {
  display: inline-flex; width: 44px; height: 4px; border-radius: 2px;
  background: #eef1f6; overflow: hidden; vertical-align: middle; margin-left: 8px;
  flex: none;
}
.mini-bar i { display: block; height: 100%; background: #c7d9fe; border-radius: 2px; }

.spark { display: block; }
.spark-cell .spark { margin: 0 auto; }

/* ---------------- 单条趋势面板 ---------------- */

.focus {
  border-top: 1px solid var(--line);
  background: #fcfdff;
}
.focus-head {
  display: flex; align-items: center; gap: 8px;
  padding: 11px 16px 0;
}
.focus-head b { font-size: calc(12.5px * var(--fs-scale)); font-weight: 620; }
.focus-head .btn-ghost { margin-left: auto; padding: 4px 9px; font-size: calc(11px * var(--fs-scale)); }
.focus-body {
  display: grid; grid-template-columns: 190px minmax(0, 1fr) minmax(0, .82fr);
  gap: 16px; padding: 10px 16px 14px; align-items: start;
}
.focus-stats { display: flex; flex-direction: column; gap: 6px; }
.focus-stats > div { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; font-size: calc(11.5px * var(--fs-scale)); }
.focus-stats span { color: var(--ink-3); }
.focus-stats b { font-weight: 600; font-variant-numeric: tabular-nums; }
.focus-chart .cap { font-size: calc(10px * var(--fs-scale)); color: var(--ink-3); text-align: center; padding-bottom: 2px; }

/* ---------------- misc ---------------- */

.pill {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: calc(11px * var(--fs-scale)); font-weight: 600;
  padding: 1.5px 6px; border-radius: 6px;
  font-variant-numeric: tabular-nums;
}
.pill.ok { background: var(--green-bg); color: var(--green); }
.pill.warn { background: var(--amber-bg); color: var(--amber); }
.pill.bad { background: var(--red-bg); color: var(--red); }
.pill.mute { background: #f2f4f8; color: var(--ink-2); }

.dim { color: var(--ink-3); }
.empty { padding: 26px 16px; text-align: center; color: var(--ink-3); font-size: calc(12.5px * var(--fs-scale)); }

.foot {
  max-width: 1560px; margin: 0 auto; padding: 0 24px 26px;
  display: flex; align-items: center; gap: 7px;
  font-size: calc(11px * var(--fs-scale)); color: var(--ink-4);
}
.foot .sep { color: #d4dae4; }

/* ---------------- drawer ---------------- */

.scrim {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(16, 24, 40, .32);
  animation: fade .18s ease;
}
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 51;
  width: min(520px, 94vw);
  background: #fff; border-left: 1px solid var(--line);
  display: flex; flex-direction: column;
  animation: slide .24s cubic-bezier(.2, .8, .2, 1);
}
@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(24px); opacity: 0; } }

.drawer-head {
  display: flex; align-items: center;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.drawer-head h2 { font-size: calc(14px * var(--fs-scale)); font-weight: 620; }
.drawer-head .x {
  margin-left: auto; border: 0; background: transparent; cursor: pointer;
  color: var(--ink-3); padding: 4px; border-radius: 6px;
}
.drawer-head .x:hover { background: #f2f4f8; color: var(--ink); }
.drawer-head .x svg { width: 16px; height: 16px; }

.drawer-body {
  padding: 16px 18px 28px; overflow-y: auto;
  font-size: calc(12.5px * var(--fs-scale)); line-height: 1.7; color: var(--ink-2);
}
.drawer-body h3 {
  font-size: calc(11px * var(--fs-scale)); font-weight: 600; color: var(--ink-3);
  letter-spacing: .05em; text-transform: uppercase;
  margin: 18px 0 7px;
}
.drawer-body h3:first-child { margin-top: 0; }
.drawer-body ul { margin: 0; padding-left: 17px; }
.drawer-body li { margin-bottom: 5px; }
.drawer-body code {
  font-family: var(--num); font-size: calc(11.5px * var(--fs-scale));
  background: #f2f4f8; padding: 1px 5px; border-radius: 4px;
  color: var(--ink);
}
.drawer-body .kv { display: grid; grid-template-columns: 118px minmax(0, 1fr); gap: 4px 12px; }
.drawer-body .kv dt { color: var(--ink-3); }
.drawer-body .kv dd { margin: 0; font-variant-numeric: tabular-nums; }
.drawer-body .note {
  background: var(--amber-bg); border: 1px solid #fde047;
  border-radius: 8px; padding: 9px 11px; color: var(--amber);
  font-size: calc(12px * var(--fs-scale)); margin-top: 10px;
}

/* ---------------- motion ---------------- */

.card { animation: rise .3s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(5px); } }

@media (prefers-reduced-motion: reduce) {
  .card, .scrim, .drawer { animation: none !important; }
  .bar i { transition: none; }
}

/* ---------------- responsive ---------------- */

@media (max-width: 1320px) {
  .row-mini { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .row-bud { grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr); }
}

@media (max-width: 1000px) {
  .focus-body { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .focus-stats { grid-column: span 2; flex-direction: row; flex-wrap: wrap; gap: 4px 18px; }
}

@media (max-width: 860px) {
  .top-inner { padding: 10px 14px 8px; }
  .top-meta { padding: 0 14px 8px; }
  main { padding: 14px 14px 22px; gap: 16px; }
  .controls { width: 100%; margin-left: 0; }
  .row-bud { grid-template-columns: minmax(0, 1fr); }
  .row-mini { grid-template-columns: minmax(0, 1fr); }
  .sec { flex-wrap: wrap; }
  .sec .right { margin-left: 0; flex-basis: 100%; }
  .issue { grid-template-columns: 48px minmax(0, 1fr); }
  .issue .mt { grid-column: 2; text-align: left; }
  .search input { width: 100%; }
  .drill-head { flex-wrap: wrap; }
  .drill-head .head-right { margin-left: 0; width: 100%; }
  .focus-body { grid-template-columns: minmax(0, 1fr); }
  .focus-stats { grid-column: auto; }
  .foot { padding: 0 14px 22px; flex-wrap: wrap; }
}

/* ---------------- 图表图例 ---------------- */

.chart-legend {
  display: flex; align-items: center; gap: 12px;
  padding: 2px 16px 0; font-size: calc(10px * var(--fs-scale)); color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.chart-legend span { display: inline-flex; align-items: center; gap: 4px; }
.chart-legend i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.chart-legend i.dash { width: 13px; height: 0; border-top: 1.5px dashed #9aa5b4; border-radius: 0; }

/* 名称列吃满，占比条贴到列尾对齐 */
.name-cell { max-width: none; width: 100%; }
.name-cell .txt { flex: 1; min-width: 0; }

/* ---------------- 达标灯 ---------------- */

.lamp {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  flex: none; vertical-align: middle;
  box-shadow: 0 0 0 2.5px transparent;
}
.lamp.lg { width: 10px; height: 10px; }
.lamp.ok { background: #12b76a; box-shadow: 0 0 0 2.5px #d1fae5; }
.lamp.warn { background: #eab308; box-shadow: 0 0 0 2.5px #fef9c3; }
.lamp.bad { background: #ef4444; box-shadow: 0 0 0 2.5px #fee2e2; }
.lamp.mute { background: #cbd3de; box-shadow: none; }

.lamp-cell { width: 22px; padding-right: 0 !important; text-align: center; }

/* 层级切换按钮带灯，一眼看出哪层出了问题 */
.seg.lamps button {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px;
}
.seg.lamps button em {
  font-style: normal; font-size: calc(10.5px * var(--fs-scale)); font-weight: 600;
  color: var(--ink-3); font-variant-numeric: tabular-nums;
}
.seg.lamps button.is-active em { color: var(--ink-2); }

/* 图例：消耗 vs 预算的差额竖线 */
.chart-legend i.gapkey {
  width: 0; height: 9px; border-left: 1.8px solid #f0a6a0; border-radius: 0;
}

.tone-bad { color: var(--red); }

/* 窗口内的预算调整提示 */
.bud-shifts {
  margin: 0 14px 10px; padding: 5px 8px;
  background: #fff8eb; border: 1px solid #fde7c0; border-radius: 7px;
  font-size: calc(10.5px * var(--fs-scale)); color: var(--amber);
  font-variant-numeric: tabular-nums;
}



/* ---------------- 数据类型标记（当日 / 逐日 / 窗口合计） ---------------- */

.dtype {
  margin-left: auto; flex: none;
  font-size: calc(9.5px * var(--fs-scale)); font-weight: 600; letter-spacing: .02em;
  color: #5b6b82; background: #f2f4f8;
  border-radius: 4px; padding: 1px 6px;
  font-variant-numeric: tabular-nums;
}

/* 当日快照条：只放焦点那一天的数字，不掺任何区间统计 */
.snap {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 12px 16px;
  display: flex; align-items: center; gap: 18px;
}
.snap-h {
  display: flex; flex-direction: column; gap: 1px;
  padding-right: 18px; border-right: 1px solid var(--line-soft);
  flex: none;
}
.snap-h b { font-size: calc(12.5px * var(--fs-scale)); font-weight: 650; letter-spacing: -.01em; }
.snap-h span { font-size: calc(10.5px * var(--fs-scale)); color: var(--ink-3); white-space: nowrap; }
.snap-b {
  flex: 1; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px 14px;
}
.snap-b > div { display: flex; flex-direction: column; gap: 1px; }
.snap-b span { font-size: calc(10.5px * var(--fs-scale)); color: var(--ink-3); }
.snap-b b {
  font-size: calc(17px * var(--fs-scale)); font-weight: 620; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}

.tone-ok { color: var(--green); }
.tone-warn { color: var(--amber); }
.tone-bad { color: var(--red); }

.chart-legend b { color: var(--ink); font-weight: 650; font-variant-numeric: tabular-nums; }

/* 核心问题的时间范围标签：这条判据是看哪一段 */
.issue .when {
  display: inline-block; margin-right: 6px;
  font-size: calc(9.5px * var(--fs-scale)); font-weight: 600; font-style: normal;
  color: #8b95a7; background: #f4f6fa;
  border: 1px solid var(--line); border-radius: 4px;
  padding: 0 5px; vertical-align: 1px;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 860px) {
  .snap { flex-direction: column; align-items: stretch; gap: 10px; }
  .snap-h { border-right: 0; padding-right: 0; }
  .snap-b { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* 口径抽屉里的预算构成（campaign 级） */
.drawer-body .bd {
  margin-top: 3px; font-size: calc(11px * var(--fs-scale)); color: var(--ink-3);
  line-height: 1.55;
}
.drawer-body .bd em { font-style: normal; color: var(--ink-4); }

.snap-live .live-note {
  display: block; font-size: calc(11.5px * var(--fs-scale)); color: var(--ink-3);
  grid-column: 1 / -1;
}

.bud-pct.unknown {
  background: #f2f4f8; color: var(--ink-3); font-weight: 550;
}

/* ---------------- 顶部 tab ---------------- */

.tabs {
  max-width: 1560px; margin: 0 auto;
  padding: 0 24px;
  display: flex; gap: 4px;
  border-bottom: 1px solid transparent;
}
.tabs button {
  border: 0; background: transparent; cursor: pointer;
  padding: 7px 12px 8px;
  font-size: calc(12.5px * var(--fs-scale)); font-weight: 560; color: var(--ink-3);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .15s, border-color .15s;
}
.tabs button:hover { color: var(--ink-2); }
.tabs button.is-active { color: var(--ink); border-bottom-color: var(--blue); }

@media (max-width: 860px) {
  .tabs { padding: 0 14px; }
}

/* 下钻头部在窄屏换行，别把层级按钮挤出去；并限宽，避免 daySeg/搜索把整卡撑出视口 */
.sec h2 { white-space: nowrap; }
.drill-head {
  flex-wrap: wrap;
  min-width: 0;
  max-width: 100%;
  width: 100%;
  box-sizing: border-box;
}
#daySeg {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  max-width: 100%;
  min-width: 0;
  flex: 1 1 auto;
}
.drill-head .head-right {
  margin-left: auto;
  min-width: 0;
  max-width: 100%;
}
.drill-head .search { min-width: 0; flex: 1 1 160px; }
.drill-head .search input { width: 100%; min-width: 0; }
.seg.lamps { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

@media (max-width: 1100px) {
  .drill-head .head-right {
    margin-left: 0; width: 100%; max-width: 100%;
    justify-content: flex-start; flex-wrap: wrap;
  }
}


/* ---------------- 日历选日期 ---------------- */

.datepick { position: relative; display: inline-flex; }

.date-chip {
  display: inline-flex; align-items: center; gap: 5px;
  border: 1px solid var(--line); background: #fff; cursor: pointer;
  border-radius: 9px; padding: 4px 10px;
  font-size: calc(12px * var(--fs-scale)); font-weight: 520; color: var(--ink-2);
  transition: border-color .15s, color .15s, background .15s;
  font-variant-numeric: tabular-nums;
}
.date-chip:hover { border-color: #cfd6e2; color: var(--ink); }
.date-chip svg { width: 13px; height: 13px; opacity: .8; }
.date-chip.is-active {
  background: var(--blue-bg); border-color: #bcd2fe;
  color: var(--blue-ink); font-weight: 620;
}
.date-chip.is-active svg { opacity: 1; }

.datepick input[type="date"] {
  position: absolute; left: 2px; bottom: 0;
  width: 1px; height: 1px; padding: 0; border: 0;
  opacity: 0; pointer-events: none;
}

@media (max-width: 860px) {
  .meta-bar .top-meta { padding: 4px 14px 5px; flex-wrap: wrap; }
  .top-meta .hint { display: none; }
}

/* ---------------- 01 预算 · 消耗 · 消耗率（一张表，可逐层展开） ---------------- */

.bs .bs-table { padding: 0 14px 4px; }
.bs-note {
  margin: 0 14px 8px; font-size: calc(10.5px * var(--fs-scale)); color: var(--ink-4);
  line-height: 1.6;
}
.bs-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 76px 76px 112px 72px 72px 72px 72px;
  align-items: center; gap: 10px;
  padding: 7px 4px;
  border-top: 1px solid var(--line-soft);
  font-size: calc(12px * var(--fs-scale));
}
.bs-row.bs-head {
  border-top: 0; padding: 2px 4px 5px;
  font-size: calc(10.5px * var(--fs-scale)); color: var(--ink-3); font-weight: 560;
}
.bs-row .nm {
  display: flex; align-items: center; gap: 6px;
  min-width: 0; overflow: hidden;
}
.bs-row .nm > b { font-weight: 650; color: var(--ink); }
.bs-row .nm em {
  font-style: normal; font-size: calc(10.5px * var(--fs-scale)); font-weight: 450;
  color: var(--ink-3); white-space: nowrap;
}
.bs-row.lv-camp .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; padding-left: 21px; }
.bs-row .num { text-align: right; font-variant-numeric: tabular-nums; }
.bs-row .num b { font-weight: 620; }

.bs-row.lv-prod { background: #fbfcfe; }
.bs-row.lv-prod .nm { font-size: calc(12.5px * var(--fs-scale)); }
.bs-row.lv-acc { padding-left: 16px; }
.bs-row.lv-acc .nm { font-size: calc(11.5px * var(--fs-scale)); }
.bs-row.lv-camp { font-size: calc(11px * var(--fs-scale)); color: var(--ink-3); }
.bs-row.bs-total {
  border-top: 1px solid var(--line);
  background: #fafbfd; font-weight: 600;
}

.bs-row .caret {
  width: 15px; height: 15px; flex: none; border: 0; background: transparent;
  cursor: pointer; color: var(--ink-3); padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 4px;
}
.bs-row .caret:hover { background: #eef1f6; color: var(--ink); }
.bs-row .caret svg { width: 11px; height: 11px; transition: transform .18s; }
.bs-row .caret.open svg { transform: rotate(90deg); }
.bs-row .caret.blank { visibility: hidden; }

.pace { display: flex; align-items: center; gap: 7px; justify-content: flex-end; }
.pace-bar {
  width: 54px; height: 4px; border-radius: 2px;
  background: #eef1f6; overflow: hidden; flex: none;
}
.pace-bar i { display: block; height: 100%; border-radius: 2px; background: #8fa8d6; }
.pace b { color: var(--ink); font-weight: 620; font-variant-numeric: tabular-nums; }

.bs-spend {
  margin: 4px 14px 12px; padding-top: 10px;
  border-top: 1px solid var(--line-soft);
}
.bs-spend .card-head { padding: 0 0 4px; }

@media (max-width: 1000px) {
  .bs-row { grid-template-columns: minmax(150px, 1fr) 60px 60px 84px 56px 56px 56px 56px; gap: 6px; font-size: calc(11.5px * var(--fs-scale)); }
  .pace-bar { width: 34px; }
}

.bs-row.can-open { cursor: pointer; }
.bs-row.can-open:hover { background: #f7f9fd; }
.bs-row.can-open .nm > b, .bs-row.can-open .nm { user-select: none; }

/* 预算表 + 消耗走势：左右结构 */
.row-bs {
  display: grid;
  grid-template-columns: minmax(0, 1.62fr) minmax(0, 1fr);
  gap: 12px;
  align-items: stretch;
}
.row-bs > .card { display: flex; flex-direction: column; }
@media (max-width: 1180px) {
  .row-bs { grid-template-columns: minmax(0, 1fr); }
}

/* 预算表底部说明贴底，别在中间留一块空白 */
.bs .bs-note { margin-top: auto; }




/* 估算标记：这条回收是按花费分摊的，不是真实归属 */
i.est {
  font-style: normal; font-size: calc(9px * var(--fs-scale)); font-weight: 600;
  color: #9aa4b4; background: #f1f3f8;
  border-radius: 3px; padding: 0 3px; margin-left: 4px;
  vertical-align: 1px; letter-spacing: .02em;
}

/* 下钻表：列宽固定，展开更深一层时右侧数字列不会重排 */
table.d.drill-t { table-layout: fixed; width: 100%; min-width: 1180px; }
table.d.drill-t col.c-name { width: auto; }
table.d.drill-t col.c-spend { width: 96px; }
table.d.drill-t col.c-d0 { width: 96px; }
table.d.drill-t col.c-adv { width: 188px; }
/* 今日 CPP 趋势箭头：涨红↑ / 跌绿↓ */
.cpp-band .cpp-arr { margin-left: 2px; font-size: .92em; font-weight: 700; }
.cpp-band .cpp-arr.up { color: #b91c1c; }
.cpp-band .cpp-arr.dn { color: #15803d; }

/* 调整建议：可换行；数值色在 JS（花费/付费人 dim；CPP 同灯色带） */
table.d.drill-t td:has(.adv-badge) { white-space: normal; vertical-align: middle; }
table.d.drill-t .adv-badge { white-space: normal !important; display: inline-block; line-height: 1.25; text-align: center; }
table.d.drill-t td.adv-merge { vertical-align: middle; text-align: center; }
table.d.drill-t .adv-stack { display: flex; flex-direction: column; align-items: center; gap: 4px; }
table.d.drill-t .adv-stack .adv-badge { max-width: 200px; }
table.d.drill-t col.c-rate { width: 118px; }
table.d.drill-t col.c-rate1 { width: 96px; }
table.d.drill-t col.c-d1 { width: 96px; }
table.d.drill-t col.c-payers { width: 76px; }
table.d.drill-t col.c-cpa { width: 88px; }
table.d.drill-t col.c-cpp { width: 84px; }
table.d.drill-t col.c-live { width: 64px; }
table.d.drill-t td.live-td { vertical-align: middle; padding-top: 4px; padding-bottom: 4px; }
table.d.drill-t .live-age { font-size: calc(12px * var(--fs-scale)); font-weight: 600; color: var(--ink-2); white-space: nowrap; }
table.d.drill-t col.c-spark { width: 86px; }
table.d.drill-t td.tree-cell {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 0; /* 配合 table-layout:fixed，强制名称列吃剩余宽并可 ellipsis */
}
table.d.drill-t td.tree-cell > .txt {
  display: inline; /* 保留灯+箭头同行；截断靠 td overflow */
}
table.d.drill-t .spark-cell { padding-left: 8px; padding-right: 10px; }


/* 窄屏：缩小数字列/内边距，封顶树缩进观感；表在 .table-wrap 内横滑，外层不撑页 */
@media (max-width: 860px) {
  .top, .meta-bar, .tabs, .foot { max-width: 100%; min-width: 0; }
  .top-inner, .top-meta { max-width: 100%; min-width: 0; }

  table.d th, table.d td { padding: 7px 8px; font-size: calc(12px * var(--fs-scale)); }
  table.d th:first-child, table.d td:first-child { padding-left: 10px; }
  table.d th:last-child, table.d td:last-child { padding-right: 10px; }

  table.d.drill-t { min-width: 800px; }
  table.d.drill-t col.c-spend { width: 78px; }
  table.d.drill-t col.c-d0 { width: 78px; }
  table.d.drill-t col.c-rate { width: 96px; }
  table.d.drill-t col.c-rate1 { width: 80px; }
  table.d.drill-t col.c-d1 { width: 78px; }
  table.d.drill-t col.c-payers { width: 64px; }
  table.d.drill-t col.c-cpa { width: 72px; }
  table.d.drill-t col.c-cpp { width: 72px; }
  table.d.drill-t col.c-live { width: 56px; }
  table.d.drill-t col.c-spark { width: 70px; }
  table.d.drill-t .spark-cell { padding-left: 4px; padding-right: 6px; }

  table.q th, table.q td { padding: 7px 8px; }


  .sec h2 { white-space: normal; }
  .drill-head { gap: 8px; }
  #daySeg { width: 100%; }
  .seg.lamps { width: 100%; }
}

/* ---------------- gate (access key) ---------------- */

.gate {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: var(--bg);
}
.gate-load {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 14px;
  width: min(280px, 100%);
  margin: 0 auto;
}
.gate-load-mark {
  width: 40px; height: 40px; color: var(--blue);
  margin: 0 auto;
}
.gate-load-mark svg { width: 40px; height: 40px; display: block; margin: 0 auto; }
.gate-load-title {
  font-size: calc(15px * var(--fs-scale)); font-weight: 650; letter-spacing: -.01em; color: var(--ink);
  line-height: 1.3;
}
.gate-spin {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--line);
  border-top-color: var(--blue);
  animation: gate-spin .7s linear infinite;
  margin: 2px auto 0;
  flex: none;
}
@keyframes gate-spin { to { transform: rotate(360deg); } }
.gate-load-text {
  font-size: calc(13px * var(--fs-scale)); font-weight: 520; color: var(--ink-2);
  line-height: 1.4;
}
.gate-card {
  width: min(360px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow), 0 12px 40px rgba(16, 24, 40, .06);
  padding: 28px 24px 24px;
}
.gate-brand {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 18px;
}
.gate-brand .mark { width: 30px; height: 30px; color: var(--blue); flex: none; }
.gate-brand .mark svg { width: 30px; height: 30px; display: block; }
.gate-brand h1 { font-size: calc(15px * var(--fs-scale)); font-weight: 650; letter-spacing: -.01em; }
.gate-brand p { font-size: calc(11px * var(--fs-scale)); color: var(--ink-3); margin-top: 1px; }
.gate-form { display: flex; flex-direction: column; gap: 10px; }
.gate-form label {
  font-size: calc(12px * var(--fs-scale)); font-weight: 560; color: var(--ink-2);
}
.gate-form input[type="password"] {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  font-size: calc(13px * var(--fs-scale)); color: var(--ink);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.gate-form input[type="password"]:focus {
  border-color: #93b4fd;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
.gate-form .btn {
  width: 100%; justify-content: center;
  padding: 9px 12px; border-radius: 9px;
  font-size: calc(13px * var(--fs-scale)); font-weight: 600;
  margin-top: 2px;
}
.gate-err {
  min-height: 18px;
  font-size: calc(12px * var(--fs-scale)); color: var(--red); font-weight: 520;
}
.gate-hint {
  margin-top: 2px;
  font-size: calc(11px * var(--fs-scale)); color: var(--ink-3); line-height: 1.45;
}

/* ---------------- pull latest overlay ---------------- */

.pull-overlay {
  position: fixed; inset: 0; z-index: 10000;
  display: flex; align-items: center; justify-content: center;
  background: rgba(244, 246, 250, .88);
  backdrop-filter: blur(6px);
  padding: 24px;
}
.pull-overlay[hidden] { display: none !important; }
.pull-overlay-inner {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: 12px;
  width: min(320px, 100%);
}
.pull-overlay-title {
  font-size: calc(15px * var(--fs-scale)); font-weight: 650; color: var(--ink); letter-spacing: -.01em;
}
.pull-overlay-sub {
  font-size: calc(12.5px * var(--fs-scale)); color: var(--ink-2); line-height: 1.45;
}
body.is-pulling { overflow: hidden; }
body.is-pulling .top, body.is-pulling main, body.is-pulling .foot {
  pointer-events: none; user-select: none;
}
table.d td.tree-cell > .txt { font-size: calc(14px * var(--fs-scale)); } /* 四层名字放大 */
/* 名字列宽 = 本表最长名（JS --name-col-w）；其后：花费 / D0付费人 / CPP区 / 率区 / 解读 / 建议 */
table.d.drill-t { table-layout: auto; }
/* 名字列宽 = 整树最长名（JS 渲染时一次写入 --name-col-w），展开收合不变，D0 列不动 */
table.d.drill-t col.c-name { width: var(--name-col-w, 240px); }
table.d.drill-t td.tree-cell { min-width: var(--name-col-w, 240px); box-sizing: border-box; }
table.d.drill-t td.tree-cell { max-width: none; overflow: visible; padding-right: 10px; }
/* 四层表第2列现为「花费」，保持右对齐（勿沿用旧「D0贴名字」左对齐） */
table.d.drill-t th:nth-child(2), table.d.drill-t td:nth-child(2) { text-align: right; padding-left: 12px; }
/* 四层 Meta 开/关小标签（最近一次拉取，级联） */
table.d td.tree-cell .txt.is-off, table.d td.tree-cell .txt.is-off b { color: #8a93a0; text-decoration: line-through; }
/* 账号层「（已禁用）」跟在划线名后面，本身不划线 */
table.d td.tree-cell .acc-disabled-tag {
  display: inline;
  margin-left: 2px;
  color: #8a93a0;
  font-size: calc(12px * var(--fs-scale, 1));
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}

/* 只看红/黄/绿 */
#toneFilter button { display: inline-flex; align-items: center; gap: 5px; }
#toneFilter .tdot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; opacity: .85; }
#toneFilter .tdot.bad { background: #ef4444; }
#toneFilter .tdot.warn { background: #eab308; }
#toneFilter .tdot.ok { background: #12b76a; }


@media (max-width: 860px) { .ok-sub { max-width: none; } }

/* 四层明细：表格上方控件行，左对齐，搜索在最右 */
.drill-ctrl { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 14px 10px; }
.drill-ctrl .search { margin-left: auto; min-width: 200px; }
.drill-ctrl .search input { width: 100%; }
@media (max-width: 640px) { .drill-ctrl .search { margin-left: 0; flex: 1 1 100%; } }

/* 顶栏常驻：meta-bar + 标题行整体悬浮；overflow-x:clip 不建滚动容器，sticky 才生效 */
html,body{overflow-x:clip !important}
.top{position:sticky !important;top:0;z-index:100;background:rgba(255,255,255,.96);box-shadow:0 4px 12px rgba(15,23,42,.06)}

/* 字号放大：窄屏收敛 */
@media (max-width: 720px) { :root { --fs-scale: 1.08; } }
html, body { line-height: 1.55; }

/* 预算表加 D1/D3/D7 后窄屏横向滚动 */
.bs-table { overflow-x: auto; }
.bs-table .bs-row { min-width: 620px; }

/* Dk 观察日当天未结束：整列虚线框 + 表头「未完」，格内照常上色 */
.prov-col { border-left: 1px dashed #d5dae2 !important; border-right: 1px dashed #d5dae2 !important; background: rgba(148,163,184,.025); }
.prov-col.pc-top { border-top: 1px dashed #d5dae2 !important; }
.prov-col.pc-bot { border-bottom: 1px dashed #d5dae2 !important; }
.prov-tag { font-style: normal; font-size: 10px; font-weight: 500; color: #94a3b8; margin-left: 4px; padding: 0 4px; border: 1px dashed #dde1e7; border-radius: 4px; }
.bs-row .num.prov-col { align-self: stretch; display: flex; align-items: center; justify-content: flex-end; padding-right: 4px; }
.bs-row.bs-total .num.prov-col { border-bottom: 1px dashed #d5dae2 !important; }
.bs-row:not(.bs-head) > .num.prov-col { margin: -7px 0; padding-top: 7px; padding-bottom: 7px; }
.bs-row.bs-head > .num.prov-col { margin: -2px 0 -5px; padding-top: 2px; padding-bottom: 5px; }

/* 表头口径小圆 i */
.tip-i {
  display: inline-flex; align-items: center; justify-content: center;
  width: 14px; height: 14px; margin-left: 3px; vertical-align: 1px;
  border-radius: 50%; border: 1px solid #94a3b8; color: #64748b;
  font-style: normal; font-size: 10px; font-weight: 700; line-height: 1;
  cursor: help; user-select: none;
}
.tip-i:hover, .tip-i:focus { border-color: #2563eb; color: #2563eb; outline: none; background: #eff6ff; }

/* 预算表并入四层明细：走势卡独占一行；顶部分产品总览 */
.row-bs.one { grid-template-columns: minmax(0, 1fr); }
table.d.drill-t col.c-ratio { width: 80px; }
table.d.drill-t tbody.ov-body tr.ov-row td { background: #f6f8fc; }
table.d.drill-t tbody.ov-body tr.ov-all td { background: #eef2f9; }
table.d.drill-t tbody.ov-body tr:last-child td { border-bottom: 2px solid #c9d2e3; }
table.d.drill-t { min-width: 1240px; }
@media (max-width: 860px) { table.d.drill-t { min-width: 960px; } table.d.drill-t col.c-ratio { width: 66px; } }

/* 表头 i 自绘浮层（即时出现） */
.tip-pop { position: fixed; z-index: 9999; display: none; max-width: 340px; padding: 8px 10px; border-radius: 8px;
  background: #1f2937; color: #f9fafb; font-size: 12px; line-height: 1.5; font-weight: 400; white-space: normal;
  box-shadow: 0 6px 20px rgba(0,0,0,.18); pointer-events: none; text-align: left; }
table.d.drill-t col.c-ratio { width: 104px; }
table.d.drill-t tbody#drillRows tr.prod-head td { background: #eef2f9; border-top: 2px solid #c9d2e3; font-size: 1.02em; }
table.d.drill-t col.c-bsc { width: 210px; }
.bsc { display: flex; align-items: center; gap: 6px; justify-content: flex-end; white-space: nowrap; font-variant-numeric: tabular-nums; }
.bsc .pace-bar { width: 46px; }
.bsc b { font-weight: 620; min-width: 34px; text-align: right; }
.bsc .bsc-n { color: var(--ink-2, #555); font-size: .92em; }
.bsc.nob .bsc-n { color: inherit; font-size: 1em; }
@media (max-width: 860px) { table.d.drill-t col.c-bsc { width: 176px; } .bsc .pace-bar { width: 30px; } }

/* t191：消耗/预算列左对齐 + 轨道加深，进度看得清 */
table.d.drill-t td:has(> .bsc), table.d.drill-t th:nth-child(2) { text-align: left; }
.bsc { justify-content: flex-start; }
.bsc .pace-bar { width: 56px; height: 8px; background: #cfd6e2; border-radius: 3px; box-shadow: inset 0 0 0 1px #b7c0d0; overflow: hidden; flex: none; }
.bsc .pace-bar i { background: #3b6fd8; border-radius: 3px; }
.kind-tag{display:inline-block;margin-left:6px;padding:0 5px;border-radius:4px;font-size:10px;font-weight:600;line-height:16px;vertical-align:middle;letter-spacing:.3px}
.kind-tag.kind-abo{color:#6b7280;background:#f3f4f6}
.kind-tag.kind-cbo{color:#1d4ed8;background:#e0ecff}
/* 2026-11-08 四层表头悬浮：表格自身纵向滚动，thead 吸顶 */
.table-wrap.drill-wrap{overflow:visible}
.drill-ctrl{position:sticky;top:var(--top-h,0px);z-index:51;background:#fff}
table.d.drill-t thead{position:sticky;top:calc(var(--top-h,0px) + var(--ctrl-h,0px));z-index:50}
table.d.drill-t thead th{background:#fff;box-shadow:inset 0 -1px 0 #e5e9f0}
table.d.drill-t tr.row-stuck > td{position:sticky;z-index:40;background:#f7f9fc;box-shadow:inset 0 -1px 0 #e5e9f0}

.seg[hidden]{display:none}

/* ===== mobile-only (<=860px): compact filters + scrollable drill table ===== */
/* PC 规则一律不动；只在窄屏取消层层吸顶，表自己横竖滑，名称列左侧冻结。 */
.m-filter-btn { display: none; }

@media (max-width: 860px) {
  .m-filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    flex: 0 1 auto;
    max-width: 58%;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 9px;
    padding: 6px 10px;
    font-size: calc(12px * var(--fs-scale));
    font-weight: 550;
    color: var(--ink-2);
    cursor: pointer;
    white-space: nowrap;
  }
  .m-filter-btn .m-filter-sum {
    color: var(--ink-3);
    font-weight: 450;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
  }
  .m-filter-btn::after {
    content: "";
    width: 6px; height: 6px;
    border-right: 1.6px solid currentColor;
    border-bottom: 1.6px solid currentColor;
    transform: rotate(45deg) translateY(-2px);
    flex: none;
    opacity: .7;
  }
  .m-filter-btn.is-open {
    border-color: #93b4fd;
    color: var(--blue-ink);
    background: var(--blue-bg);
  }
  .m-filter-btn.is-open::after { transform: rotate(-135deg) translateY(-1px); }

  /* 顶栏不再吸顶，避免和筛选条、表头叠成半屏 */
  .top {
    position: relative !important;
    box-shadow: none;
  }
  .top-inner {
    padding: 8px 12px;
    gap: 8px;
  }
  .brand p { display: none; }
  .mark, .mark svg { width: 24px; height: 24px; }
  .who { display: none; }

  /* 盖过先前 .meta-bar .top-meta { flex-wrap: wrap }，收成一行可横滑 */
  .meta-bar .top-meta,
  .top-meta {
    padding: 4px 12px;
    min-height: 24px;
    flex-wrap: nowrap !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }
  .top-meta > * { flex: none; white-space: nowrap; }
  .top-meta .grow { display: none; }
  #benchHint { display: none; }

  .tabs { padding: 0 12px; }

  /* 默认收起产品和日期筛选；点「筛选」再展开 */
  body:not(.is-m-filters-open) .top-inner .controls { display: none; }
  body.is-m-filters-open .top-inner .controls {
    display: flex;
    width: 100%;
    margin-left: 0;
  }

  /* 四层筛选条：默认收进「筛选」；展开后不再吸顶 */
  .drill-ctrl { position: static !important; }
  body:not(.is-m-filters-open) .drill-ctrl { display: none; }
  body.is-m-filters-open .drill-ctrl {
    display: flex;
    position: static !important;
    padding: 10px 12px 8px;
  }

  main { padding: 10px 10px 16px; gap: 12px; }
  .sec { flex-wrap: nowrap; gap: 8px; padding: 0; }
  .sec .desc { display: none; }
  .sec .right {
    margin-left: auto;
    flex: 1 1 auto;
    flex-basis: auto;
    min-width: 0;
    max-width: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: right;
  }

  /* 四层表自己滚动：左右能滑，表头在容器内吸顶 */
  .table-wrap.drill-wrap {
    overflow: auto !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-x pan-y;
    max-height: calc(100vh - var(--m-chrome-h, 168px));
    max-height: calc(100dvh - var(--m-chrome-h, 168px));
  }

  table.d.drill-t {
    --name-col-w: 176px !important;
    border-collapse: separate;
    border-spacing: 0;
  }
  table.d.drill-t col.c-name { width: 176px; }
  table.d.drill-t thead {
    position: sticky;
    top: 0 !important;
    z-index: 6;
  }
  table.d.drill-t thead th { background: #fff; }

  /* 名称列左侧固定，横滑时仍能对上是哪一行；限宽省略号 */
  table.d.drill-t thead th:first-child,
  table.d.drill-t tbody td.tree-cell,
  table.d.drill-t tfoot td:first-child {
    position: sticky;
    left: 0;
    z-index: 3;
    max-width: 176px !important;
    min-width: 176px !important;
    width: 176px;
    overflow: hidden;
    box-shadow: 6px 0 8px -6px rgba(15, 23, 42, .18);
  }
  table.d.drill-t thead th:first-child {
    z-index: 7;
    background: #fff;
    white-space: normal;
    line-height: 1.25;
  }
  table.d.drill-t tfoot td:first-child { z-index: 4; background: #fafbfd; }
  table.d.drill-t tbody td.tree-cell {
    display: flex;
    align-items: center;
    background: #fff;
    overflow: hidden !important;
    white-space: nowrap;
  }
  table.d.drill-t td.tree-cell > .lamp,
  table.d.drill-t td.tree-cell > .caret,
  table.d.drill-t td.tree-cell > .kind-tag,
  table.d.drill-t td.tree-cell > .acc-disabled-tag {
    flex: none;
  }
  table.d.drill-t td.tree-cell > .txt {
    display: block;
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  table.d.drill-t tbody.ov-body tr.ov-row > td.tree-cell { background: #f6f8fc; }
  table.d.drill-t tbody.ov-body tr.ov-all > td.tree-cell { background: #eef2f9; }
  table.d.drill-t tbody#drillRows tr.prod-head > td.tree-cell { background: #eef2f9; }
  table.d.drill-t tbody#drillRows tr.lv-agent > td.tree-cell { background: #f8fafc; }
  table.d.drill-t tbody tr:hover > td.tree-cell { background: #fafbfd; }
  table.d.drill-t tbody tr.is-focus > td.tree-cell { background: var(--blue-bg); }
}
