/* ============================================================
 * screen.css · 平台数据大屏（1920×1080 设计稿，等比缩放投屏）
 *
 * 除下面这段「宿主容器」外，全部规则都收在 #screen-root 作用域内：
 * 大屏走深色、控制台走浅色，两份样式表里的 --bg / --ink / --line 取值相反，
 * 全局生效会把控制台刷黑。改写由 scripts/scope-screen-css.py 机械完成。
 * ============================================================ */

/* ---------- 宿主容器 ----------
 * 两个场景共用同一份大屏：工作台正文内嵌（#/screen 路由）/ 独立投屏页 screen.html。
 * 本体固定 1920×1080，靠 JS 按宿主尺寸等比缩放；宿主只提供一块定位上下文 + 暗底，
 * 免得缩放后四周漏出控制台的白背景。
 */
.screen-embed {
  position: relative; width: 100%; height: 100%;
  overflow: hidden; background: #050A18;
  border-radius: 14px; isolation: isolate;
}
/* 注意：下面几条必须用 #screen-root 提权重。
   作用域里的 `#screen-root { position: relative; width/height: 100% }` 是 ID 选择器，
   类名选择器压不过它 —— 之前写成 .screen-embed.in-console，外放时 position 没被改掉，
   画面就缩在正文里不动。 */
/* 正文内嵌：高度吃满可视区（顶栏 62 + 内边距 24），不留页面滚动条 */
#screen-root.in-console {
  height: calc(100vh - 86px);
  min-height: 520px;
  box-shadow: 0 18px 48px rgba(10, 18, 48, .18);
}
/* 大屏页把正文内边距收到 12px —— 24px 的留白等于白送掉 24px 画面高度 */
.content.is-screen { padding: 12px; overflow: hidden; }
/* 外放：脱离文档流铺满视口，盖住侧栏与顶栏（控制台里也能当投屏用） */
body.casting #screen-root {
  position: fixed; inset: 0; z-index: 960;
  width: 100vw; height: 100vh; min-height: 0; border-radius: 0;
}
@media (max-width: 900px) {
  /* 手机上按 16:9 排，否则整屏只剩一条缝 */
  #screen-root.in-console { height: auto; aspect-ratio: 16 / 9; min-height: 0; }
}

#screen-root {
  --bg: #050A18;
  --panel: rgba(11, 21, 45, .82);
  --panel-2: rgba(16, 30, 60, .72);
  --line: rgba(79, 140, 255, .22);
  --line-soft: rgba(79, 140, 255, .1);
  --brand: #4F8CFF;
  --cyan: #35E0D0;
  --violet: #8B5CF6;
  --ok: #22D39A;
  --warn: #FFB020;
  --danger: #FF5C7A;
  --ink: #E9EFFF;
  --ink2: #B4C2E4;
  --muted: #7486AE;
  --font: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

#screen-root,
#screen-root * { box-sizing: border-box; }
#screen-root [hidden] { display: none !important; }
#screen-root {
  position: relative; width: 100%; height: 100%;
  margin: 0; padding: 0; overflow: hidden;
  background: var(--bg); color: var(--ink);
  font-family: var(--font); font-size: 14px;
  -webkit-font-smoothing: antialiased;
  line-height: 1.3; text-align: left;
}

/* ---------- 背景 ---------- */
#screen-root .bg-grid {
  position: absolute; inset: 0; z-index: 0;
  background-image:
    linear-gradient(rgba(79, 140, 255, .05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(79, 140, 255, .05) 1px, transparent 1px);
  background-size: 60px 60px;
  mask-image: radial-gradient(circle at 50% 40%, #000 20%, transparent 78%);
  -webkit-mask-image: radial-gradient(circle at 50% 40%, #000 20%, transparent 78%);
}
#screen-root .bg-glow {
  position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(900px 420px at 50% -6%, rgba(79, 140, 255, .22), transparent 70%),
    radial-gradient(700px 380px at 6% 92%, rgba(53, 224, 208, .1), transparent 72%),
    radial-gradient(760px 400px at 96% 88%, rgba(139, 92, 246, .12), transparent 72%);
}

/* ---------- 舞台 ---------- */
#screen-root .stage {
  position: absolute; left: 50%; top: 50%;
  width: 1920px; height: 1080px;
  transform-origin: center center;
  transform: translate(-50%, -50%) scale(1);
  display: flex; flex-direction: column;
  padding: 18px 22px 8px;
  z-index: 1;
}

/* ---------- 头部 ---------- */
#screen-root .hd {
  height: 72px; flex: 0 0 72px;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  position: relative;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 14px;
}
#screen-root .hd::after {
  content: ""; position: absolute; left: 50%; bottom: -1px; width: 520px; height: 1px;
  transform: translateX(-50%);
  background: linear-gradient(90deg, transparent, var(--brand), transparent);
  opacity: .75;
}
#screen-root .hd-l { display: flex; align-items: center; gap: 14px; }
#screen-root .logo {
  width: 42px; height: 42px; border-radius: 12px; flex: 0 0 42px;
  display: grid; place-items: center;
  font-size: 22px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, #6D5BFF, #4F8CFF);
  box-shadow: 0 0 0 1px rgba(120, 160, 255, .35), 0 8px 24px rgba(79, 140, 255, .35);
}
#screen-root .logo.lg { width: 56px; height: 56px; flex: 0 0 56px; font-size: 28px; margin: 0 auto 18px; }
#screen-root .titles h1 { margin: 0; font-size: 21px; font-weight: 700; letter-spacing: .6px; }
#screen-root .titles p { margin: 3px 0 0; font-size: 12px; color: var(--muted); letter-spacing: 1.4px; }

#screen-root .hd-c { text-align: center; }
#screen-root .clock-row { display: flex; align-items: center; justify-content: center; gap: 9px; }
#screen-root .clock-row b { font-family: var(--mono); font-size: 25px; font-weight: 600; letter-spacing: 2px; }
#screen-root .date-row { font-size: 12px; color: var(--muted); letter-spacing: 1px; margin-top: 1px; }
#screen-root .pulse {
  width: 8px; height: 8px; border-radius: 50%; background: var(--ok);
  box-shadow: 0 0 0 0 rgba(34, 211, 154, .7);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(34, 211, 154, .55); }
  70% { box-shadow: 0 0 0 9px rgba(34, 211, 154, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 211, 154, 0); }
}

#screen-root .hd-r { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
#screen-root .pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 11px; border-radius: 14px;
  font-size: 12px; color: var(--ink2);
  background: rgba(79, 140, 255, .1); border: 1px solid var(--line);
}
#screen-root .pill .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }
#screen-root .pill.warn { color: var(--warn); border-color: rgba(255, 176, 32, .35); background: rgba(255, 176, 32, .1); }
#screen-root .pill.warn .dot { background: var(--warn); }
#screen-root .pill.mock { color: var(--violet); border-color: rgba(139, 92, 246, .4); background: rgba(139, 92, 246, .12); }
#screen-root .pill.mock .dot { background: var(--violet); }
#screen-root .hbtn {
  height: 28px; padding: 0 11px; border-radius: 8px; cursor: pointer;
  font-size: 12px; color: var(--ink2); font-family: inherit;
  background: rgba(255, 255, 255, .04); border: 1px solid var(--line);
  transition: .15s; text-decoration: none; display: inline-flex; align-items: center;
}
#screen-root .hbtn:hover { color: #fff; border-color: rgba(79, 140, 255, .6); background: rgba(79, 140, 255, .16); }

/* ---------- 主体三列 ---------- */
#screen-root .bd {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: 452px 1fr 468px; gap: 14px;
}
#screen-root .col { display: flex; flex-direction: column; gap: 14px; min-height: 0; }

/* ---------- 面板 ---------- */
#screen-root .panel {
  position: relative; min-height: 0;
  display: flex; flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  backdrop-filter: blur(3px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .03), 0 10px 30px rgba(0, 0, 0, .35);
}
/* 四角装饰 */
#screen-root .panel::before,
#screen-root .panel::after {
  content: ""; position: absolute; width: 12px; height: 12px; pointer-events: none;
  border-color: rgba(79, 140, 255, .75); border-style: solid;
}
#screen-root .panel::before { left: -1px; top: -1px; border-width: 2px 0 0 2px; border-top-left-radius: 10px; }
#screen-root .panel::after { right: -1px; bottom: -1px; border-width: 0 2px 2px 0; border-bottom-right-radius: 10px; }

#screen-root .ph {
  flex: 0 0 auto; height: 40px; padding: 0 14px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--line-soft);
}
#screen-root .ph h2 {
  margin: 0; font-size: 14.5px; font-weight: 600; letter-spacing: .4px;
  padding-left: 10px; position: relative;
}
#screen-root .ph h2::before {
  content: ""; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 13px; border-radius: 2px;
  background: linear-gradient(180deg, var(--cyan), var(--brand));
}
#screen-root .ph-x { margin-left: auto; font-size: 11.5px; color: var(--muted); }
#screen-root .ph-x b { color: var(--ink2); font-family: var(--mono); font-weight: 600; }
#screen-root .pb { flex: 1; min-height: 0; padding: 12px 14px; overflow: hidden; }

/* ---------- KPI ---------- */
#screen-root .kpis { flex: 0 0 138px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
#screen-root .kpi {
  position: relative; padding: 16px 16px 12px; border-radius: 10px;
  background: linear-gradient(160deg, rgba(79, 140, 255, .16), rgba(11, 21, 45, .7) 62%);
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .05);
  overflow: hidden;
}
#screen-root .kpi::after {
  content: ""; position: absolute; right: -30px; top: -30px; width: 96px; height: 96px;
  border-radius: 50%; background: radial-gradient(circle, rgba(79, 140, 255, .3), transparent 70%);
}
#screen-root .kpi-k { font-size: 12px; color: var(--muted); letter-spacing: .6px; }
#screen-root .kpi-v {
  margin: 8px 0 6px; font-family: var(--mono); font-size: 33px; font-weight: 600;
  letter-spacing: -.5px; line-height: 1.1; color: #fff;
  font-variant-numeric: tabular-nums;
}
#screen-root .kpi:nth-child(1) .kpi-v { color: #8FD0FF; }
#screen-root .kpi:nth-child(3) .kpi-v { color: #FFCF7A; }
#screen-root .kpi:nth-child(4) .kpi-v { color: #7CF0DC; }
#screen-root .kpi-d { font-size: 11.5px; color: var(--muted); }

/* ---------- 环形图 ---------- */
#screen-root .pb-donut { display: flex; align-items: center; gap: 6px; }
#screen-root .donut-box { position: relative; width: 232px; height: 232px; flex: 0 0 232px; }
#screen-root .donut-box svg { width: 100%; height: 100%; }
#screen-root .donut-center {
  position: absolute; inset: 0; display: grid; place-content: center; text-align: center;
  pointer-events: none;
}
#screen-root .donut-center b {
  font-family: var(--mono); font-size: 32px; font-weight: 600; color: #fff; line-height: 1;
}
#screen-root .donut-center span { display: block; margin-top: 5px; font-size: 11.5px; color: var(--muted); }
#screen-root .legend { list-style: none; margin: 0; padding: 0; flex: 1; min-width: 0; }
#screen-root .legend li {
  display: flex; align-items: center; gap: 8px;
  padding: 6.5px 0; font-size: 12.5px; color: var(--ink2);
  border-bottom: 1px dashed rgba(79, 140, 255, .1);
}
#screen-root .legend li:last-child { border-bottom: 0; }
#screen-root .legend .sw { width: 9px; height: 9px; border-radius: 3px; flex: 0 0 9px; }
#screen-root .legend .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#screen-root .legend .vl { font-family: var(--mono); color: #fff; font-weight: 600; }
#screen-root .legend .pc { font-family: var(--mono); color: var(--muted); width: 44px; text-align: right; }

/* ---------- 漏斗 ---------- */
#screen-root .funnel-row { margin-bottom: 15px; }
#screen-root .funnel-row:last-child { margin-bottom: 0; }
#screen-root .funnel-top {
  display: flex; align-items: baseline; gap: 8px; margin-bottom: 7px;
  font-size: 12.5px; color: var(--ink2);
}
#screen-root .funnel-top .idx {
  width: 18px; height: 18px; border-radius: 5px; flex: 0 0 18px;
  display: grid; place-items: center; font-family: var(--mono); font-size: 11px;
  color: var(--brand); background: rgba(79, 140, 255, .14);
}
#screen-root .funnel-top .vl { margin-left: auto; font-family: var(--mono); color: #fff; font-weight: 600; font-size: 14px; }
#screen-root .funnel-top .pu { color: var(--muted); font-family: var(--mono); font-size: 11.5px; width: 48px; text-align: right; }
#screen-root .funnel-bar {
  height: 17px; border-radius: 4px; overflow: hidden;
  background: rgba(79, 140, 255, .07); position: relative;
}
#screen-root .funnel-bar i {
  display: block; height: 100%; border-radius: 4px;
  transition: width .8s cubic-bezier(.22, .61, .36, 1);
  box-shadow: 0 0 14px rgba(79, 140, 255, .4);
}

/* ---------- 趋势图 ---------- */
#screen-root #trend { width: 100%; height: 100%; display: block; }
#screen-root .grid-line { stroke: rgba(79, 140, 255, .13); stroke-width: 1; }
#screen-root .axis-txt { fill: #6B7CA6; font-size: 11px; font-family: var(--mono); }
#screen-root .trend-area { fill: url(#areaGrad); }
#screen-root .trend-line { fill: none; stroke: #4F8CFF; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
#screen-root .trend-pt { fill: #0A1530; stroke: #7CF0DC; stroke-width: 2; }
#screen-root .trend-pt:hover { r: 6; }

/* ---------- 实时动态 ---------- */
#screen-root .pb-live { padding: 0; display: flex; flex-direction: column; }
#screen-root .live-head,
#screen-root .live-row {
  display: grid; grid-template-columns: 96px 50px 1fr 90px 76px;
  align-items: center; gap: 8px; padding: 0 14px;
}
#screen-root .live-head {
  height: 30px; flex: 0 0 30px; font-size: 11px; color: var(--muted);
  background: rgba(79, 140, 255, .06); letter-spacing: .5px;
}
#screen-root .live-body { flex: 1; min-height: 0; overflow: hidden; position: relative; }
#screen-root .live-row {
  height: 33px; font-size: 12.5px; color: var(--ink2);
  border-bottom: 1px solid rgba(79, 140, 255, .07);
  animation: rowIn .45s ease both;
}
@keyframes rowIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
#screen-root .live-row .r { text-align: right; }
#screen-root .live-row .tm { font-family: var(--mono); font-size: 11.5px; color: var(--muted); white-space: nowrap; line-height: 1; }
#screen-root .live-row .tp {
  font-size: 11px; padding: 1px 7px; border-radius: 4px; justify-self: start;
  color: var(--brand); background: rgba(79, 140, 255, .13); white-space: nowrap;
}
#screen-root .live-row .tp.demand { color: var(--cyan); background: rgba(53, 224, 208, .13); }
#screen-root .live-row .tt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
#screen-root .live-row .am { font-family: var(--mono); text-align: right; color: #FFCF7A; }
#screen-root .live-row .st { text-align: right; font-size: 11.5px; }
#screen-root .st.ok { color: var(--ok); }
 #screen-root .st.warn { color: var(--warn); }
 #screen-root .st.mute { color: var(--muted); }
 #screen-root .st.bad { color: var(--danger); }

/* ---------- 算力池 ---------- */
#screen-root .pool-sum { margin-bottom: 15px; padding-bottom: 14px; border-bottom: 1px solid rgba(79, 140, 255, .1); }
#screen-root .ps-top { display: flex; align-items: baseline; gap: 9px; margin-bottom: 9px; }
#screen-root .ps-top b { font-family: var(--mono); font-size: 27px; font-weight: 600; color: #7CF0DC; line-height: 1; }
#screen-root .ps-top .lb { font-size: 12px; color: var(--muted); }
#screen-root .ps-top .rg { margin-left: auto; font-size: 11.5px; color: var(--muted); }
#screen-root .ps-nums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 11px; }
#screen-root .ps-nums div { display: flex; flex-direction: column; gap: 2px; }
#screen-root .ps-nums span { font-size: 11px; color: var(--muted); }
#screen-root .ps-nums b { font-family: var(--mono); font-size: 15.5px; font-weight: 600; color: var(--ink2); }
#screen-root .pool-row { margin-bottom: 13px; }
#screen-root .pool-row:last-child { margin-bottom: 0; }
#screen-root .pool-top { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; font-size: 12.5px; }
#screen-root .pool-top .nm { color: var(--ink); font-weight: 600; }
#screen-root .pool-top .rg { color: var(--muted); font-size: 11.5px; }
#screen-root .pool-top .vl { margin-left: auto; font-family: var(--mono); font-size: 12.5px; color: var(--ink2); }
#screen-root .pool-top .lv {
  font-size: 10.5px; padding: 0 6px; border-radius: 4px; margin-left: 6px;
  font-family: var(--mono);
}
#screen-root .lv.OVERLOAD { color: var(--danger); background: rgba(255, 92, 122, .16); }
#screen-root .lv.HIGH { color: var(--warn); background: rgba(255, 176, 32, .16); }
#screen-root .lv.NORMAL { color: var(--ok); background: rgba(34, 211, 154, .14); }
#screen-root .pool-bar { height: 9px; border-radius: 5px; background: rgba(79, 140, 255, .1); overflow: hidden; }
#screen-root .pool-bar i {
  display: block; height: 100%; border-radius: 5px;
  background: linear-gradient(90deg, #4F8CFF, #35E0D0);
  transition: width .8s cubic-bezier(.22, .61, .36, 1);
}
#screen-root .pool-bar i.hot { background: linear-gradient(90deg, #FFB020, #FF5C7A); }

/* ---------- 渠道 ---------- */
#screen-root .pb-channel { display: flex; flex-direction: column; }
#screen-root .ch-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 10px; }
#screen-root .ch-grid div { display: flex; flex-direction: column; gap: 4px; }
#screen-root .ch-grid span { font-size: 11.5px; color: var(--muted); }
#screen-root .ch-grid b {
  font-family: var(--mono); font-size: 23px; font-weight: 600; color: #8FD0FF;
  line-height: 1; font-variant-numeric: tabular-nums;
}
#screen-root .ch-foot {
  display: flex; justify-content: space-between; align-items: baseline;
  margin: 14px 0 7px; font-size: 11.5px; color: var(--muted);
}
#screen-root .ch-foot span:last-child { font-family: var(--mono); color: var(--ink2); }
#screen-root .ch-bar { margin-top: auto; height: 6px; border-radius: 3px; background: rgba(79, 140, 255, .1); overflow: hidden; }
#screen-root .ch-bar i {
  display: block; height: 100%; width: 0; border-radius: 3px;
  background: linear-gradient(90deg, #35E0D0, #4F8CFF);
  transition: width .9s cubic-bezier(.22, .61, .36, 1);
}

/* ---------- 风险 ---------- */
#screen-root .risk { display: flex; flex-direction: column; gap: 10px; }
#screen-root .risk-item {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 12px; border-radius: 8px;
  background: rgba(79, 140, 255, .06);
  border-left: 2px solid var(--brand);
}
#screen-root .risk-item.warn { border-left-color: var(--warn); background: rgba(255, 176, 32, .07); }
#screen-root .risk-item.bad { border-left-color: var(--danger); background: rgba(255, 92, 122, .07); }
#screen-root .risk-item.ok { border-left-color: var(--ok); background: rgba(34, 211, 154, .06); }
#screen-root .risk-item .r-ic { font-size: 17px; width: 22px; text-align: center; opacity: .9; }
#screen-root .risk-item .r-tx { flex: 1; min-width: 0; }
#screen-root .risk-item .r-tx b { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink); }
#screen-root .risk-item .r-tx span { font-size: 11px; color: var(--muted); }
#screen-root .risk-item .r-vl { font-family: var(--mono); font-size: 21px; font-weight: 600; color: #fff; }

/* ---------- 页脚 ---------- */
#screen-root .ft {
  flex: 0 0 26px; height: 26px; margin-top: 6px;
  display: flex; align-items: center;
  font-size: 11px; color: #55658C; letter-spacing: .5px;
}
#screen-root .ft .spacer { flex: 1; }

/* ============================================================
 * 外放（投放）模式
 * 目标场景：会议室电视 / 展厅大屏 / 值班室挂屏 —— 无人值守整夜开着。
 * 所以这里只做四件事：全屏、轮播、防熄屏、失败不静默。
 * ============================================================ */

/* 头部「外放」按钮走主色，和其他工具按钮区分开 */
#screen-root .hbtn.cast {
  color: #fff; border-color: transparent;
  background: linear-gradient(120deg, #6D5BFF, #4F8CFF);
  box-shadow: 0 6px 16px rgba(79, 140, 255, .32);
}
#screen-root .hbtn.cast:hover { background: linear-gradient(120deg, #7C6BFF, #5F98FF); }
#screen-root .hbtn.cast.on { background: linear-gradient(120deg, #FF5C7A, #FF8A5C); box-shadow: 0 6px 16px rgba(255, 92, 122, .3); }

/* 外放中：藏掉一切「操作向」的控件，只留数据源状态（实时 / 演示 / 断开必须一眼可辨） */
body.casting #screen-root .hd-r .hbtn,
body.casting #screen-root .hd-r #upd-pill,
body.casting #screen-root .ft { display: none; }
body.casting #screen-root .hd-r #src-pill { opacity: .72; }
body.casting #screen-root .hd { height: 64px; flex-basis: 64px; }
body.casting #screen-root .titles p { opacity: .5; }
body.casting #screen-root .logo { box-shadow: 0 0 0 1px rgba(120, 160, 255, .35), 0 0 26px rgba(79, 140, 255, .5); }

/* 外放时主体让出底部空间，别让控制条压在面板上 */
body.casting #screen-root .stage { padding-bottom: 54px; }

/* ---------- 版面轮播：display:contents 把三列拆开，panel 直接落进网格 ---------- */
#screen-root .stage[data-pg="2"] .bd {
  grid-template-columns: 1fr 1.12fr;
  grid-template-rows: 138px 1.08fr 1fr;
  grid-template-areas: "kpi kpi" "donut trend" "funnel live";
}
#screen-root .stage[data-pg="3"] .bd {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 138px 1.06fr .86fr;
  grid-template-areas: "kpi kpi" "pool ch" "risk risk";
}
#screen-root .stage[data-pg="2"] .col,
#screen-root .stage[data-pg="3"] .col { display: contents; }

#screen-root .stage[data-pg="2"] .pg-kpi,
#screen-root .stage[data-pg="3"] .pg-kpi { grid-area: kpi; }
#screen-root .stage[data-pg="2"] .pg-donut { grid-area: donut; }
#screen-root .stage[data-pg="2"] .pg-funnel { grid-area: funnel; }
#screen-root .stage[data-pg="2"] .pg-trend { grid-area: trend; }
#screen-root .stage[data-pg="2"] .pg-live { grid-area: live; }
#screen-root .stage[data-pg="3"] .pg-pool { grid-area: pool; }
#screen-root .stage[data-pg="3"] .pg-ch { grid-area: ch; }
#screen-root .stage[data-pg="3"] .pg-risk { grid-area: risk; }

#screen-root .stage[data-pg="2"] .pg-pool,
#screen-root .stage[data-pg="2"] .pg-ch,
#screen-root .stage[data-pg="2"] .pg-risk,
#screen-root .stage[data-pg="3"] .pg-donut,
#screen-root .stage[data-pg="3"] .pg-funnel,
#screen-root .stage[data-pg="3"] .pg-trend,
#screen-root .stage[data-pg="3"] .pg-live { display: none; }

/* 单版面时空间变大，图形跟着放大，不然四周全是空白 */
#screen-root .stage[data-pg="2"] .donut-box { width: 306px; height: 306px; flex: 0 0 306px; }
#screen-root .stage[data-pg="2"] .donut-center b { font-size: 40px; }
#screen-root .stage[data-pg="2"] .legend li { padding: 9px 0; font-size: 13px; }
#screen-root .stage[data-pg="2"] .funnel-row { margin-bottom: 18px; }
#screen-root .stage[data-pg="2"] .funnel-bar { height: 20px; }
#screen-root .stage[data-pg="3"] .pool-row { margin-bottom: 16px; }
#screen-root .stage[data-pg="3"] .pool-bar { height: 11px; }
#screen-root .stage[data-pg="3"] .ch-grid b { font-size: 30px; }

/* 风险四项横排：单列纵向排 4 条会把下半屏拉得很空 */
#screen-root .stage[data-pg="3"] .risk { flex-direction: row; gap: 12px; height: 100%; }
#screen-root .stage[data-pg="3"] .risk-item {
  flex: 1; min-width: 0; flex-direction: column; align-items: flex-start;
  justify-content: center; gap: 6px; padding: 20px 18px;
  border-left-width: 3px;
}
#screen-root .stage[data-pg="3"] .risk-item .r-ic { font-size: 22px; width: auto; line-height: 1; }
/* 竖排时 .r-tx 的 flex:1 会把数值顶到卡片底部，这里收回来自适应 */
#screen-root .stage[data-pg="3"] .risk-item .r-tx { flex: 0 0 auto; }
#screen-root .stage[data-pg="3"] .risk-item .r-vl { font-size: 34px; line-height: 1; margin-top: 4px; }
#screen-root .stage[data-pg="3"] .risk-item .r-tx b { font-size: 14px; }
#screen-root .stage[data-pg="3"] .risk-item .r-tx span { display: block; margin-top: 3px; }

/* 单版面下面板变成大块，内容太少会缩在顶部 —— 用 space-between 把留白摊开 */
#screen-root .stage[data-pg="3"] .pg-pool .pb,
#screen-root .stage[data-pg="3"] .pg-ch .pb { display: flex; flex-direction: column; justify-content: space-around; }
/* space-around 与 margin-top:auto 抢位置，这里让进度条也参与均分 */
#screen-root .stage[data-pg="3"] .ch-bar { margin-top: 0; }

/* ---------- 外放控制条 ---------- */
#screen-root .castbar {
  position: absolute; left: 50%; bottom: 26px; z-index: 6;
  height: 42px; padding: 0 8px 0 14px;
  display: flex; align-items: center; gap: 14px;
  border-radius: 999px;
  background: rgba(9, 17, 38, .86);
  border: 1px solid rgba(79, 140, 255, .3);
  box-shadow: 0 14px 40px rgba(0, 0, 0, .55);
  backdrop-filter: blur(8px);
  transform: translateX(-50%);
  transition: opacity .5s ease, transform .5s ease;
  font-size: 12px; color: var(--ink2);
  white-space: nowrap;
}
#screen-root .cb-prog {
  position: absolute; left: 12px; right: 12px; bottom: 0; height: 2px;
  border-radius: 2px; background: linear-gradient(90deg, var(--cyan), var(--brand));
  transform-origin: left center; transform: scaleX(0);
  transition: transform .28s linear;
}
#screen-root .cb-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 11px; color: #fff; letter-spacing: .5px;
  background: linear-gradient(120deg, #FF5C7A, #FF8A5C);
}
#screen-root .cb-badge::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: #fff; animation: blink 1.6s infinite;
}
#screen-root .cb-badge.paused { background: linear-gradient(120deg, #5A6B93, #7486AE); }
#screen-root .cb-badge.paused::before { animation: none; opacity: .8; }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
#screen-root .cb-pg { display: inline-flex; align-items: baseline; gap: 8px; }
#screen-root .cb-pg b { font-family: var(--mono); font-size: 13px; color: #fff; }
#screen-root .cb-pg em { font-style: normal; color: var(--ink2); }
#screen-root .cb-dots { display: flex; align-items: center; gap: 6px; }
#screen-root .cb-dots i {
  width: 22px; height: 4px; border-radius: 2px; cursor: pointer;
  background: rgba(79, 140, 255, .28); transition: .25s;
}
#screen-root .cb-dots i.on { background: linear-gradient(90deg, var(--cyan), var(--brand)); }
#screen-root .cb-tip { color: var(--muted); font-size: 11.5px; }
#screen-root .cb-btn {
  height: 28px; padding: 0 14px; border-radius: 999px; cursor: pointer;
  font-size: 12px; font-family: inherit; color: var(--danger);
  background: rgba(255, 92, 122, .12); border: 1px solid rgba(255, 92, 122, .35);
  transition: .15s;
}
#screen-root .cb-btn:hover { color: #fff; background: rgba(255, 92, 122, .28); }

/* 鼠标静止后：控制条淡出、光标隐藏 —— 投屏画面不该出现一个箭头 */
body.idle #screen-root,
body.idle #screen-root * { cursor: none !important; }
body.idle #screen-root .castbar { opacity: 0; pointer-events: none; transform: translate(-50%, 12px); }

/* ---------- 断链横幅 ---------- */
/* 挂在头部右侧：外放时那一带只有数据源状态，用它顶上去最不打扰画面 */
#screen-root .netbar {
  position: absolute; right: 24px; top: 22px; z-index: 7;
  display: flex; align-items: center; gap: 10px;
  padding: 9px 18px; border-radius: 999px;
  font-size: 13px; color: #FFD7DE;
  background: rgba(255, 92, 122, .16);
  border: 1px solid rgba(255, 92, 122, .5);
  box-shadow: 0 10px 30px rgba(255, 92, 122, .22);
  backdrop-filter: blur(6px);
  animation: netIn .3s ease both;
}
#screen-root .netbar b { font-size: 15px; }
#screen-root .netbar.ok { color: #CFF6EA; background: rgba(34, 211, 154, .14); border-color: rgba(34, 211, 154, .45); }
@keyframes netIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }

/* ---------- 未登录遮罩 ---------- */
#screen-root .gate {
  position: absolute; inset: 0; z-index: 20;
  display: grid; place-items: center;
  background: rgba(3, 7, 18, .92); backdrop-filter: blur(6px);
}
#screen-root .gate-card {
  width: 460px; padding: 40px 36px; text-align: center;
  border-radius: 16px; border: 1px solid var(--line);
  background: var(--panel); box-shadow: 0 24px 60px rgba(0, 0, 0, .55);
}
#screen-root .gate-card h2 { margin: 0 0 12px; font-size: 19px; }
#screen-root .gate-card p { margin: 0 0 22px; font-size: 13px; line-height: 1.85; color: var(--muted); }
#screen-root .gate-acts { display: flex; gap: 12px; justify-content: center; margin-bottom: 20px; }
#screen-root .gbtn {
  height: 38px; padding: 0 22px; border-radius: 9px; text-decoration: none;
  display: inline-flex; align-items: center; font-size: 13.5px; color: var(--ink2);
  border: 1px solid var(--line); background: rgba(255, 255, 255, .04);
}
#screen-root .gbtn.primary { color: #fff; border-color: transparent; background: linear-gradient(120deg, #6D5BFF, #4F8CFF); }
#screen-root .gate-tip { font-size: 11.5px; color: #55658C; margin: 0 !important; }
#screen-root .gate-tip code {
  font-family: var(--mono); padding: 1px 5px; border-radius: 4px;
  background: rgba(79, 140, 255, .14); color: var(--ink2);
}
