/* ============================================================
 *  SFS · 智能制造全流程仿真 · 深色工业风样式
 * ============================================================ */
:root {
  --bg: #0b0f14;
  --bg-2: #0f151d;
  --panel: #131b24;
  --panel-2: #172030;
  --line: #22303f;
  --line-soft: #1b2735;
  --txt: #dfe7ef;
  --txt-dim: #8b98a8;
  --txt-mute: #5f6d7d;
  --acc: #35c5f3;
  --ok: #3fb950;
  --warn: #e3b341;
  --bad: #ff6b6b;
  --info: #58a6ff;
  --violet: #bc8cff;
  --orange: #f0883e;
  --mono: "JetBrains Mono", "Cascadia Mono", Consolas, "Courier New", monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--txt);
  font: 13px/1.55 system-ui, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  overflow: hidden;
}
#app { display: grid; grid-template-columns: 190px 1fr; height: 100vh; }

/* ---------------- 侧边导航 ---------------- */
.sidebar { background: linear-gradient(180deg, #0d141c, #0a0e13); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; }
.brand { padding: 14px 14px 12px; border-bottom: 1px solid var(--line-soft); }
.brand h1 { margin: 0; font-size: 15px; letter-spacing: .5px; }
.brand h1 span { color: var(--acc); }
.brand p { margin: 3px 0 0; font-size: 10.5px; color: var(--txt-mute); letter-spacing: .3px; }
nav.nav { padding: 8px 8px 12px; overflow-y: auto; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 9px; width: 100%; padding: 9px 10px; margin: 2px 0;
  background: none; border: 0; border-radius: 7px; color: var(--txt-dim); cursor: pointer;
  font-size: 12.5px; text-align: left; transition: background .15s, color .15s;
}
.nav-item:hover { background: #16202b; color: var(--txt); }
.nav-item.on { background: #14273a; color: #e6f6ff; box-shadow: inset 2px 0 0 var(--acc); }
.nav-ico { width: 17px; text-align: center; font-size: 13px; opacity: .9; }
.nav-txt { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-badge { font: 10px var(--mono); color: var(--txt-mute); background: #0e1720; border: 1px solid var(--line-soft); border-radius: 10px; padding: 0 6px; }
.nav-item.on .nav-badge { color: var(--acc); border-color: #1d3a52; }
.side-foot { padding: 8px 10px 12px; border-top: 1px solid var(--line-soft); font-size: 10.5px; color: var(--txt-mute); }
.side-foot code { font-family: var(--mono); color: #7d8ea0; }

/* ---------------- 主区 ---------------- */
.main { display: flex; flex-direction: column; min-width: 0; background: var(--bg); }
.topbar { display: flex; align-items: center; gap: 14px; padding: 8px 14px; border-bottom: 1px solid var(--line); background: var(--bg-2); flex-wrap: wrap; }
.clock { display: flex; align-items: baseline; gap: 8px; }
.clock-date { font: 600 15px var(--mono); color: #eaf3fb; }
.clock-time { font: 600 15px var(--mono); color: var(--acc); }
.clock-tag { font-size: 10.5px; color: var(--txt-mute); }
.speed { display: flex; align-items: center; gap: 4px; background: #0d151d; border: 1px solid var(--line); border-radius: 8px; padding: 3px; }
.speed button { background: none; border: 0; color: var(--txt-dim); font: 11.5px var(--mono); padding: 3px 9px; border-radius: 5px; cursor: pointer; }
.speed button:hover { color: var(--txt); background: #16212c; }
.speed button.on { background: var(--acc); color: #04121b; font-weight: 700; }
.top-actions { display: flex; gap: 6px; margin-left: auto; flex-wrap: wrap; }
.btn { background: #17222e; border: 1px solid var(--line); color: #cdd8e4; border-radius: 7px; padding: 5px 11px; font-size: 12px; cursor: pointer; transition: .15s; }
.btn:hover { background: #1e2c3a; border-color: #2d4154; color: #fff; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: #12445c; border-color: #1b6c8e; color: #d7f4ff; }
.btn.primary:hover { background: #17546f; }
.btn.warn { background: #3a2a12; border-color: #6b4d1b; color: #ffe2a8; }
.btn.danger { background: #3a1a1a; border-color: #6b2424; color: #ffc9c9; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 2px 8px; font-size: 11px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* KPI 条 */
.kpi-strip { display: flex; gap: 8px; padding: 8px 14px; border-bottom: 1px solid var(--line); background: #0c131a; overflow-x: auto; }
.chip { flex: 1 1 0; min-width: 128px; background: linear-gradient(180deg, #131d27, #101821); border: 1px solid var(--line-soft); border-radius: 8px; padding: 7px 10px; }
.chip .c-label { font-size: 10.5px; color: var(--txt-mute); display: flex; gap: 5px; align-items: center; }
.chip .c-label i { font-style: normal; font-family: var(--mono); color: #4d6478; }
.chip .c-value { font: 600 16px var(--mono); color: #eaf3fb; margin-top: 1px; white-space: nowrap; }
.chip .c-note { font-size: 10.5px; color: var(--txt-dim); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.c-value.ok { color: var(--ok); } .c-value.warn { color: var(--warn); } .c-value.bad { color: var(--bad); } .c-value.info { color: var(--acc); }

/* 面板 */
.scroller { flex: 1; overflow-y: auto; padding: 12px 14px 26px; }
.panel { display: none; }
.panel.on { display: block; }
.panel-head { display: flex; align-items: center; gap: 10px; margin: 2px 0 10px; }
.panel-head h2 { margin: 0; font-size: 14.5px; letter-spacing: .4px; }
.panel-sub { font-size: 11.5px; color: var(--txt-mute); }
.panel-tools { margin-left: auto; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

.grid { display: grid; gap: 10px; }
.g6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.g5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g23 { grid-template-columns: 2fr 1fr; }
.g32 { grid-template-columns: 1fr 2fr; }
.mb { margin-bottom: 10px; }

.card { background: var(--panel); border: 1px solid var(--line-soft); border-radius: 10px; overflow: hidden; min-width: 0; }
.card > h3 { margin: 0; padding: 9px 12px; font-size: 12.5px; font-weight: 600; color: #cfe0ef; border-bottom: 1px solid var(--line-soft); background: #141d27; display: flex; align-items: center; gap: 8px; }
.card > h3 .hint { margin-left: auto; font-size: 10.5px; color: var(--txt-mute); font-weight: 400; }
.card-body { padding: 10px 12px; }
.card-body.tight { padding: 0; }
canvas.chart { width: 100%; height: 158px; display: block; }
canvas.chart.tall { height: 210px; }
canvas.chart.short { height: 116px; }
canvas.gauge { width: 100%; height: 112px; display: block; }
canvas.spark { width: 66px; height: 20px; display: inline-block; vertical-align: middle; }

/* KPI 卡 */
.kpi { background: linear-gradient(180deg, #141e29, #101821); border: 1px solid var(--line-soft); border-radius: 10px; padding: 9px 11px; min-width: 0; }
.kpi .k-label { font-size: 11px; color: var(--txt-mute); display: flex; align-items: center; gap: 5px; }
.kpi .k-label i { font-style: normal; font-family: var(--mono); font-size: 9.5px; color: #4d6478; letter-spacing: .4px; }
.kpi .k-value { font: 600 19px var(--mono); color: #eaf3fb; margin-top: 2px; letter-spacing: -.4px; white-space: nowrap; }
.kpi .k-value.ok { color: var(--ok); } .kpi .k-value.warn { color: var(--warn); } .kpi .k-value.bad { color: var(--bad); } .kpi .k-value.info { color: var(--acc); }
.kpi .k-note { font-size: 10.5px; color: var(--txt-dim); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .k-bar { height: 3px; background: #0c141c; border-radius: 2px; margin-top: 6px; overflow: hidden; }
.kpi .k-bar span { display: block; height: 100%; background: var(--acc); }

/* 表格 */
.tbl-wrap { overflow: auto; max-height: 420px; }
.tbl-wrap.h300 { max-height: 300px; } .tbl-wrap.h520 { max-height: 520px; } .tbl-wrap.h620 { max-height: 620px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 11.8px; }
table.tbl th { position: sticky; top: 0; z-index: 2; background: #16202b; color: #9fb0c0; font-weight: 600; text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; font-size: 11px; }
table.tbl td { padding: 5px 8px; border-bottom: 1px solid #16202a; color: #c6d2de; white-space: nowrap; }
table.tbl tbody tr:hover td { background: #16212c; }
table.tbl td.num, table.tbl th.num { text-align: right; font-family: var(--mono); font-size: 11.4px; }
table.tbl td.mono { font-family: var(--mono); font-size: 11.2px; }
table.tbl td.dim, table.tbl .dim { color: var(--txt-mute); }
table.tbl td.pos { color: var(--ok); } table.tbl td.neg { color: var(--bad); } table.tbl td.mid { color: var(--warn); }
table.tbl tr.sub td { background: #101922; color: var(--txt-dim); font-size: 11px; }
table.tbl tr.hl td { background: #14212e; }
.tbl .wrap { white-space: normal; min-width: 200px; }

/* 徽标 / 状态 */
.badge { display: inline-block; font-size: 10.5px; padding: 1px 7px; border-radius: 10px; border: 1px solid; line-height: 1.5; white-space: nowrap; }
.b-ok { color: #6ee787; border-color: #1d5a2c; background: #10241a; }
.b-warn { color: #ffd982; border-color: #63501d; background: #241f10; }
.b-bad { color: #ff9b9b; border-color: #632727; background: #241214; }
.b-info { color: #79c0ff; border-color: #1d4a6d; background: #101f2c; }
.b-mute { color: #8b98a8; border-color: #2a3745; background: #141c25; }
.b-vio { color: #d2a8ff; border-color: #4a2d6d; background: #1b1226; }

/* 迷你条 */
.bm { display: inline-block; width: 62px; height: 6px; background: #0c141c; border-radius: 3px; overflow: hidden; vertical-align: middle; margin-right: 6px; }
.bm i { display: block; height: 100%; background: var(--ok); }
.bm i.w { background: var(--warn); } .bm i.b { background: var(--bad); } .bm i.i { background: var(--info); }

/* 统计行 */
.stat-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; border-bottom: 1px dashed #1a2532; font-size: 11.8px; }
.stat-row:last-child { border-bottom: 0; }
.stat-row .sr-k { color: var(--txt-dim); flex: 1; min-width: 0; }
.stat-row .sr-v { font-family: var(--mono); color: #e2ecf5; white-space: nowrap; }
.stat-row .sr-v i { font-style: normal; font-size: 10px; color: var(--txt-mute); margin-left: 4px; }

/* 事件流 */
.log { font-size: 11.6px; max-height: 300px; overflow-y: auto; }
.log-line { display: flex; gap: 7px; padding: 3px 10px; border-bottom: 1px solid #141d26; }
.log-line:hover { background: #16202a; }
.lg-t { font-family: var(--mono); font-size: 10.5px; color: var(--txt-mute); flex: 0 0 84px; }
.lg-m { flex: 0 0 46px; font-size: 10px; text-align: center; border-radius: 8px; border: 1px solid #253141; color: #9db0c2; }
.lg-x { flex: 1; min-width: 0; color: #c2cfdb; }
.log-line.lv-warn .lg-x { color: #ffd982; }
.log-line.lv-err .lg-x { color: #ff9b9b; }
.log-line.lv-ok .lg-x { color: #a6e6b8; }
.log-line.lv-err { background: #1c1114; }
.log-line.lv-warn { background: #191611; }

/* 设备瓦片 */
.mgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(126px, 1fr)); gap: 7px; }
.mch { background: #101922; border: 1px solid var(--line-soft); border-left: 3px solid var(--txt-mute); border-radius: 7px; padding: 6px 8px; min-width: 0; }
.mch.RUN { border-left-color: var(--ok); } .mch.PM { border-left-color: var(--warn); }
.mch.DOWN { border-left-color: var(--bad); } .mch.IDLE { border-left-color: #3b4a5a; }
.mch .m-id { font: 600 11.5px var(--mono); color: #dbe7f2; }
.mch .m-nm { font-size: 10.5px; color: var(--txt-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mch .m-st { font-size: 10.5px; margin-top: 2px; }
.mch .m-hp { height: 3px; background: #0b1319; border-radius: 2px; margin-top: 5px; overflow: hidden; }
.mch .m-hp i { display: block; height: 100%; background: var(--ok); }
.mch .m-hp i.w { background: var(--warn); } .mch .m-hp i.b { background: var(--bad); }

/* 工位看板 */
.ws-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(206px, 1fr)); gap: 10px; }
.ws { background: linear-gradient(180deg, #13202b, #101821); border: 1px solid var(--line-soft); border-radius: 9px; padding: 9px 10px; }
.ws .w-top { display: flex; align-items: baseline; gap: 6px; }
.ws .w-id { font: 600 12px var(--mono); color: #cfe6f7; }
.ws .w-nm { font-size: 11px; color: var(--txt-dim); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ws .w-util { font: 600 17px var(--mono); }
.ws .w-track { height: 5px; background: #0b1319; border-radius: 3px; margin: 6px 0 7px; overflow: hidden; }
.ws .w-track i { display: block; height: 100%; }
.ws .w-facts { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 10.5px; color: var(--txt-mute); }
.ws .w-facts b { font-family: var(--mono); font-weight: 600; color: #b9c8d6; }

/* 流程图 Flow */
.flow { display: flex; align-items: stretch; gap: 6px; overflow-x: auto; padding: 4px 0 8px; }
.fnode { flex: 1 1 0; min-width: 132px; background: linear-gradient(180deg, #14212d, #101a23); border: 1px solid var(--line-soft); border-radius: 9px; padding: 8px 9px; position: relative; }
.fnode.act { border-color: #1e5f7d; box-shadow: 0 0 0 1px rgba(53,197,243,.18), inset 0 0 22px rgba(53,197,243,.07); }
.fnode .f-t { font-size: 11.5px; color: #d7e6f4; font-weight: 600; }
.fnode .f-e { font-size: 9.5px; color: var(--txt-mute); font-family: var(--mono); letter-spacing: .3px; }
.fnode .f-v { font: 600 17px var(--mono); color: var(--acc); margin-top: 3px; }
.fnode .f-s { font-size: 10.5px; color: var(--txt-dim); }
.farrow { flex: 0 0 18px; display: flex; align-items: center; justify-content: center; color: #2f6d8b; font-size: 14px; }
.flane { display: grid; grid-template-columns: 84px 1fr; gap: 8px; align-items: center; }
.flane .fl-k { font-size: 11px; color: var(--txt-mute); text-align: right; }
.facts { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 11.5px; color: var(--txt-dim); }
.facts b { font-family: var(--mono); color: #dbe7f2; font-weight: 600; }

/* 标签页 */
.tabs { display: flex; gap: 4px; }
.tabs button { background: #101922; border: 1px solid var(--line); color: var(--txt-dim); border-radius: 6px; padding: 3px 10px; font-size: 11.5px; cursor: pointer; }
.tabs button.on { background: #16415a; border-color: #1f6a8c; color: #d9f4ff; }

/* 提示 */
.empty { padding: 18px 12px; text-align: center; color: var(--txt-mute); font-size: 12px; }
.note { font-size: 11px; color: var(--txt-mute); padding: 6px 10px; }
.toast { position: fixed; right: 16px; bottom: 16px; background: #142430; border: 1px solid #1f5f7d; color: #d6f2ff; padding: 9px 14px; border-radius: 8px; font-size: 12px; box-shadow: 0 8px 26px rgba(0,0,0,.5); opacity: 0; transform: translateY(8px); transition: .2s; pointer-events: none; z-index: 99; }
.toast.on { opacity: 1; transform: none; }
.legend-inline { display: flex; gap: 12px; font-size: 10.5px; color: var(--txt-mute); padding: 4px 10px 8px; }
.legend-inline i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 4px; }

/* 滚动条 */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: #0c1218; }
::-webkit-scrollbar-thumb { background: #22303f; border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: #2d4051; }

@media (max-width: 1280px) {
  .g6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .g5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g23, .g32 { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  #app { grid-template-columns: 56px 1fr; }
  .nav-txt, .brand p, .nav-badge, .side-foot { display: none; }
  .g3, .g2 { grid-template-columns: 1fr; }
}

/* ---------- 前端异常提示条 UI Error Banner ---------- */
.ui-err{position:fixed;right:16px;bottom:16px;z-index:9999;max-width:460px;display:flex;flex-wrap:wrap;
  align-items:center;gap:8px;padding:10px 12px;border-radius:8px;background:#2a1416;border:1px solid #7d2b2f;
  color:#ff9b9b;font:12px/1.5 system-ui,"Microsoft YaHei",sans-serif;box-shadow:0 8px 24px rgba(0,0,0,.5)}
.ui-err b{color:#ff7b72}
.ui-err span{flex:1 1 100%;color:#e6c6c6;font-family:var(--mono,ui-monospace,Consolas,monospace)}
.ui-err .btn.sm{padding:2px 8px;font-size:11px}
