:root {
  --bg: #0d141b;
  --bg2: #121c25;
  --panel: #16232e;
  --panel2: #1b2b37;
  --line: #23384a;
  --line2: #2d4a5f;
  --text: #d7e3ec;
  --text2: #8fa6b8;
  --accent: #17b3a3;
  --accent2: #0e8f83;
  --warn: #e0a33c;
  --danger: #d95757;
  --ok: #4fb36b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(1000px 500px at 20% 0%, #14313a 0%, transparent 60%),
    radial-gradient(800px 400px at 90% 100%, #0f2a30 0%, transparent 55%),
    var(--bg);
}

.login-card {
  width: 380px;
  padding: 34px 32px 26px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .45);
}

.login-title {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: .5px;
}

.login-sub {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text2);
  line-height: 1.7;
}

.field {
  display: block;
  margin-top: 16px;
}

.field span {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--text2);
}

.field input,
.field select {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  color: var(--text);
  background: var(--bg2);
  border: 1px solid var(--line2);
  border-radius: 6px;
  outline: none;
  font-size: 14px;
}

.field input:focus,
.field select:focus { border-color: var(--accent); }

.login-tip {
  margin-top: 16px;
  font-size: 11.5px;
  line-height: 1.7;
  color: #6f869a;
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  color: var(--text);
  background: var(--panel2);
  border: 1px solid var(--line2);
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  transition: .15s;
  white-space: nowrap;
}

.btn:hover { border-color: var(--accent); color: #fff; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent2); border-color: var(--accent); color: #eafffb; }
.btn.primary:hover { background: var(--accent); }
.btn.danger { border-color: #6b3030; background: #3a1d1d; color: #ffb9b9; }
.btn.ghost { background: transparent; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn.block { width: 100%; margin-top: 24px; height: 40px; font-size: 15px; letter-spacing: 4px; }

/* ---------- 布局 ---------- */
.shell { display: flex; min-height: 100vh; }

.side {
  width: 208px;
  flex: 0 0 208px;
  background: var(--bg2);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--accent), #0b5f59);
  font-weight: 700;
  font-size: 13px;
  color: #eafffb;
}

.brand-text strong { display: block; font-size: 13px; }
.brand-text span { display: block; font-size: 10.5px; color: var(--text2); letter-spacing: .5px; }

.nav { flex: 1; overflow-y: auto; padding: 10px 8px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  margin-bottom: 3px;
  border-radius: 6px;
  color: var(--text2);
  cursor: pointer;
  font-size: 13px;
  border-left: 2px solid transparent;
}

.nav-item:hover { background: var(--panel); color: var(--text); }
.nav-item.active { background: var(--panel2); color: #fff; border-left-color: var(--accent); }
.nav-item i { font-style: normal; font-size: 14px; width: 16px; text-align: center; opacity: .9; }

.side-foot {
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--text2);
}

.stat-mini { display: flex; justify-content: space-between; padding: 3px 0; }
.stat-mini b { color: var(--accent); font-weight: 600; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 54px;
  flex: 0 0 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  background: var(--bg2);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.crumb { font-size: 14px; font-weight: 600; }
.topright { display: flex; align-items: center; gap: 12px; }
.tag { font-size: 11.5px; padding: 3px 9px; border: 1px solid var(--line2); border-radius: 12px; color: var(--accent); }
.clock { font-size: 12px; color: var(--text2); font-variant-numeric: tabular-nums; }

.view { padding: 18px; }

/* ---------- 通用组件 ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 14px; gap: 12px; }
.page-head h2 { margin: 0; font-size: 17px; font-weight: 700; }
.page-head p { margin: 5px 0 0; font-size: 12px; color: var(--text2); line-height: 1.6; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
}

.card h3 { margin: 0 0 10px; font-size: 13.5px; font-weight: 600; color: #eaf4fa; }
.card-sub { font-size: 11.5px; color: var(--text2); margin: -4px 0 10px; line-height: 1.6; }

.grid { display: grid; gap: 12px; }
.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: 1.35fr 1fr; }

.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 13px 15px; }
.kpi .k { font-size: 11.5px; color: var(--text2); }
.kpi .v { margin-top: 6px; font-size: 21px; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.kpi .u { font-size: 11.5px; color: var(--text2); margin-left: 4px; font-weight: 400; }
.kpi .d { margin-top: 4px; font-size: 11px; color: var(--text2); }

table.tb { width: 100%; border-collapse: collapse; font-size: 12px; }
table.tb th { text-align: left; padding: 8px 10px; background: var(--panel2); color: #cfe0ec; font-weight: 600; border-bottom: 1px solid var(--line2); white-space: nowrap; }
table.tb td { padding: 7px 10px; border-bottom: 1px solid var(--line); color: var(--text); }
table.tb tr:hover td { background: #182833; }
.tb .num { text-align: right; font-variant-numeric: tabular-nums; }
.tb .center { text-align: center; }

.pill { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11px; border: 1px solid var(--line2); color: var(--text2); white-space: nowrap; }
.pill.ok { color: #9fe4b4; border-color: #2f6741; background: #142c1d; }
.pill.warn { color: #f0cf94; border-color: #6b542a; background: #2f2614; }
.pill.bad { color: #f0a8a8; border-color: #6b3030; background: #331a1a; }

select.ctl, input.ctl {
  height: 32px;
  padding: 0 10px;
  color: var(--text);
  background: var(--bg2);
  border: 1px solid var(--line2);
  border-radius: 6px;
  font-size: 12.5px;
  font-family: inherit;
  outline: none;
}

input.ctl[type="range"] { padding: 0; border: none; background: transparent; accent-color: var(--accent); }

.list-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
}
.list-row:hover { background: #182833; }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .muted { color: var(--text2); font-size: 11.5px; }

.scroll { overflow: auto; }
.mono { font-family: Consolas, "Courier New", monospace; }

canvas { display: block; }

.tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tab { padding: 6px 13px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--text2); cursor: pointer; font-size: 12.5px; }
.tab.active { border-color: var(--accent); color: #eafffb; background: var(--panel2); }

.empty { padding: 26px; text-align: center; color: var(--text2); font-size: 12.5px; }

/* ---------- 仿真工作区 ---------- */
.sim-wrap { display: grid; grid-template-columns: 300px minmax(0, 1fr) 260px; gap: 12px; align-items: start; }

.editor-box { position: relative; }
.editor {
  width: 100%;
  height: 300px;
  padding: 10px 12px;
  color: #cfe6ef;
  background: #0b1319;
  border: 1px solid var(--line2);
  border-radius: 6px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12.5px;
  line-height: 1.62;
  resize: vertical;
  outline: none;
  tab-size: 4;
}

.statusbar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  padding: 8px 10px;
  background: #0b1319;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: Consolas, monospace;
  font-size: 11.5px;
  margin-top: 8px;
}

.sb-item .k { color: #6f8ba0; }
.sb-item .v { color: #7fe3d4; font-weight: 600; font-variant-numeric: tabular-nums; }

.panel-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.pbtn {
  height: 32px;
  background: var(--panel2);
  border: 1px solid var(--line2);
  border-radius: 5px;
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}
.pbtn:hover { border-color: var(--accent); }
.pbtn.on { background: #123f3a; border-color: var(--accent); color: #bff7ee; }

.alarm-list { max-height: 176px; overflow: auto; font-size: 11.5px; }
.alarm-item { padding: 6px 8px; border-left: 3px solid var(--warn); background: #1e2429; margin-bottom: 4px; border-radius: 3px; line-height: 1.5; }
.alarm-item .t { color: #7f97a8; margin-right: 6px; }
.alarm-item.bad { border-left-color: var(--danger); }
.alarm-item.info { border-left-color: var(--accent); }

.timeline { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.timeline input[type="range"] { flex: 1; accent-color: var(--accent); }

/* ---------- 操作过程录制 / 回放 ---------- */
.rec-panel { margin-top: 10px; padding: 10px 12px; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; }
.rec-title { font-size: 12.5px; color: var(--text); font-weight: 600; margin-right: 4px; }
.rec-track { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.rec-track input[type="range"] { flex: 1; accent-color: var(--accent); }
.rec-count { font-size: 11.5px; color: var(--text2); min-width: 64px; text-align: right; font-variant-numeric: tabular-nums; }
.rec-state { margin-top: 7px; font-size: 11.5px; line-height: 1.7; color: var(--text2); font-variant-numeric: tabular-nums; }
.rec-events { margin-top: 7px; max-height: 108px; overflow: auto; border-top: 1px dashed var(--line); padding-top: 6px; }
.rec-ev { display: block; font-size: 11.5px; line-height: 1.7; padding: 2px 6px; border-left: 3px solid var(--accent); background: #1e2429; border-radius: 3px; margin-bottom: 3px; cursor: pointer; color: var(--text2); text-decoration: none; }
.rec-ev:hover { background: #243038; color: var(--text); }
.rec-ev b { color: var(--accent); margin-right: 6px; font-variant-numeric: tabular-nums; }
.rec-ev.warn, .rec-ev.warning { border-left-color: var(--warn); }
.rec-ev.err, .rec-ev.crash, .rec-ev.bad { border-left-color: var(--danger); }

#canvasHost { position: relative; background: #0a1116; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
#simCanvas { width: 100%; height: 520px; }

.legend { position: absolute; right: 10px; top: 10px; background: rgba(10, 17, 22, .82); border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; font-size: 11px; line-height: 1.8; color: var(--text2); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; }

/* ---------- 库页 ---------- */
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.lib-card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px; cursor: pointer; transition: .15s; }
.lib-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.lib-card.on { border-color: var(--accent); background: var(--panel2); }
.lib-card canvas { width: 100%; height: 96px; background: #0b1319; border-radius: 5px; }
.lib-card .nm { margin-top: 9px; font-size: 12.5px; font-weight: 600; }
.lib-card .meta { margin-top: 4px; font-size: 11px; color: var(--text2); line-height: 1.6; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }
.filters .grow { flex: 1; min-width: 160px; }

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  padding: 11px 16px;
  background: var(--panel2);
  border: 1px solid var(--accent);
  border-radius: 7px;
  font-size: 12.5px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
  z-index: 100;
  max-width: 360px;
  line-height: 1.6;
}

.bar { height: 6px; background: #0e1a22; border-radius: 4px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); }

@media (max-width: 1360px) {
  .sim-wrap { grid-template-columns: 270px minmax(0, 1fr); }
  .sim-wrap > .col-right { grid-column: 1 / -1; }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ===== 三维模型库 ===== */
.mdl-wrap { display: grid; grid-template-columns: 290px minmax(0,1fr) 290px; gap: 12px; align-items: start; }
.mdl-left, .mdl-right { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 0 0 12px; }
.mdl-tabs { display: flex; gap: 4px; padding: 8px 10px 4px; flex-wrap: wrap; }
.mdl-tab { font-size: 12px; padding: 4px 9px; border: 1px solid var(--line); border-radius: 5px; cursor: pointer; color: var(--text2); }
.mdl-tab b { margin-left: 5px; color: var(--accent); font-weight: 600; }
.mdl-tab.active { border-color: var(--accent); color: #fff; background: rgba(23,179,163,.12); }
.mdl-list { max-height: 520px; overflow: auto; padding: 6px 10px; }
.mdl-item { padding: 7px 9px; border: 1px solid transparent; border-radius: 6px; cursor: pointer; margin-bottom: 4px; }
.mdl-item:hover { background: rgba(255,255,255,.03); }
.mdl-item.active { border-color: var(--accent); background: rgba(23,179,163,.10); }
.mdl-item-t { font-size: 12.5px; color: var(--text); }
.mdl-item-s { font-size: 11px; color: var(--text3, var(--text2)); margin-top: 2px; }
.mdl-stage { position: relative; background: #0a1016; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; height: 620px; }
.gl-host { position: absolute; inset: 0; }
.gl-canvas { display: block; width: 100%; height: 100%; cursor: grab; }
.gl-canvas:active { cursor: grabbing; }
.gl-fail { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #d9a05b; font-size: 13px; }
.mdl-hud { position: absolute; left: 12px; top: 10px; z-index: 3; pointer-events: none; }
.mdl-hud b { display: block; font-size: 14px; color: #eaf4f6; text-shadow: 0 1px 3px #000; }
.mdl-hud span { font-size: 11.5px; color: #9fb4bd; }
.gl-toolbar { position: absolute; left: 10px; right: 10px; bottom: 10px; display: flex; gap: 5px; align-items: center; flex-wrap: wrap; z-index: 3; }
.gl-tip { font-size: 11px; color: #7f939c; margin-left: auto; }
.ctl { padding: 4px 12px 10px; }
.ctl label { display: flex; justify-content: space-between; font-size: 12px; color: var(--text2); margin-bottom: 4px; }
.ctl b { color: var(--accent); font-weight: 600; }
.ctl input[type=range] { width: 100%; }
.ctl.row { display: flex; gap: 6px; }
.btn.on { border-color: var(--accent); color: #9ff3e8; background: rgba(23,179,163,.14); }
.panel-hd.sub { font-size: 12px; padding: 10px 12px 6px; color: var(--text2); border-top: 1px solid var(--line); margin-top: 6px; }
.part-list { max-height: 160px; overflow: auto; padding: 0 10px; }
.part-row { display: flex; align-items: center; gap: 6px; font-size: 11.5px; padding: 3px 2px; border-bottom: 1px dashed rgba(255,255,255,.04); }
.part-row .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); opacity: .8; }
.part-row .pn { flex: 1; color: var(--text2); }
.part-row .pv { color: var(--text3, #7f939c); cursor: pointer; }
.clash-out { margin: 8px 12px 4px; font-size: 11.5px; line-height: 1.55; color: var(--text2); background: #0f1a22; border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; }
.clash-out .ok { color: var(--accent); }
.clash-out .bad { color: var(--danger); }
.spec-list { padding: 2px 12px; }
.spec-list div { display: flex; justify-content: space-between; font-size: 11.5px; padding: 4px 0; border-bottom: 1px dashed rgba(255,255,255,.05); }
.spec-list span { color: var(--text2); }
.spec-list b { color: var(--text); font-weight: 500; }
.hint { font-size: 11px; color: #7f939c; margin-left: 6px; font-weight: 400; }

/* ---------- 程序编辑器行号栏（条款 7.1） ---------- */
.ed-row { display: flex; align-items: stretch; }
.ln-col {
  flex: 0 0 42px; width: 42px; height: 300px; box-sizing: border-box;
  overflow: hidden; padding: 10px 6px 0 0;
  background: #091015; border: 1px solid var(--line2); border-right: none; border-radius: 6px 0 0 6px;
  font-family: Consolas, "Courier New", monospace; font-size: 12.5px; line-height: 1.62;
  color: #52697a; text-align: right; user-select: none; font-variant-numeric: tabular-nums;
}
.ln-col .ln { display: block; padding: 0 2px; border-right: 2px solid transparent; }
.ln-col .ln.warn { color: #e0a33c; border-right-color: #e0a33c; background: #1d1a10; }
.ln-col .ln.err { color: #ff8a8a; border-right-color: #d95757; background: #2a1414; font-weight: 700; }
.ed-row .editor { flex: 1; width: auto; border-left-color: #091015; border-radius: 0 6px 6px 0; resize: none; }
.alarm-item.jump { cursor: pointer; }
.alarm-item.jump:hover { background: #26333c; }
.fx-canvas { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
