:root {
  --bg: #eef1f6;
  --card: #fff;
  --sidebar: #0f172a;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --accent: #2563eb;
  --accent-soft: #dbeafe;
  --teal: #0d9488;
  --ok: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
  --mono: "Cascadia Code", Consolas, monospace;
  --state-online: #22c55e;
  --state-busy: #f59e0b;
  --state-offline: #94a3b8;
  --state-unknown: #cbd5e1;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 200px;
  background: var(--sidebar);
  color: #94a3b8;
  padding: 1rem 0.65rem;
  flex-shrink: 0;
}

.brand {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  padding: 0.25rem 0.5rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
  margin-bottom: 0.75rem;
}

.brand-dot {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, #3b82f6, #14b8a6);
}
.brand-logo {
  width: 34px; height: 34px;
  border-radius: 8px;
  object-fit: contain;
  background: #fff;
  padding: 1px;
}

.brand strong { color: #f8fafc; font-size: 0.9rem; display: block; }
.brand small { font-size: 0.62rem; opacity: 0.5; }

.nav-modules { list-style: none; margin: 0; padding: 0; }
.nav-modules li {
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
  margin-bottom: 2px;
}
.nav-modules li.active {
  background: rgba(37,99,235,.35);
  color: #fff;
  font-weight: 600;
}
.nav-modules li.disabled { opacity: 0.4; cursor: not-allowed; }
.nav-modules li .tag {
  float: right;
  font-size: 0.6rem;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(255,255,255,.1);
}

.nav-agent {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-top: 0.6rem;
  padding: 0.6rem 0.65rem;
  border-radius: 10px;
  text-decoration: none;
  background: linear-gradient(135deg, rgba(59,130,246,.25), rgba(20,184,166,.22));
  border: 1px solid rgba(96,165,250,.35);
}
.nav-agent:hover { border-color: rgba(96,165,250,.7); background: linear-gradient(135deg, rgba(59,130,246,.4), rgba(20,184,166,.32)); }
.nav-agent .na-dot {
  width: 26px; height: 26px; border-radius: 7px; flex-shrink: 0;
  background: linear-gradient(135deg, #3b82f6, #14b8a6);
}
.nav-agent .na-txt { line-height: 1.25; min-width: 0; }
.nav-agent .na-txt strong { display: block; color: #f8fafc; font-size: 0.82rem; }
.nav-agent .na-txt small { color: #cbd5e1; font-size: 0.6rem; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }

.module-loading {
  position: absolute;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(238, 241, 246, 0.92);
  backdrop-filter: blur(2px);
}
.module-loading.hidden { display: none; }
.ml-box { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 1.1rem; }
.ml-spinner {
  width: 54px; height: 54px;
  border-radius: 50%;
  border: 5px solid #dbe2ec;
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
.ml-box p { margin: 0; font-size: 0.95rem; color: var(--muted); font-weight: 500; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.eyebrow { margin: 0; font-size: 0.72rem; color: var(--muted); letter-spacing: 0.06em; }
.topbar h1 { margin: 0.2rem 0 0; font-size: 1.2rem; }
.topbar-right { display: flex; gap: 0.5rem; align-items: center; }

.badge, .recipe-badge {
  font-size: 0.75rem;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  background: #f1f5f9;
  color: var(--muted);
}
.badge.running { background: #fef3c7; color: var(--warn); }
.badge.completed { background: #dcfce7; color: var(--ok); }
.badge.error, .badge.stopped { background: #fee2e2; color: var(--danger); }
.recipe-badge { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.panel-active { flex: 1; padding: 1rem 1.25rem 1.25rem; overflow: auto; }
.panel-placeholder.hidden { display: none; }

/* 流动化学（外部系统嵌入） */
.panel-flow { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.panel-flow.hidden { display: none; }
.flow-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1.25rem;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
.flow-title { font-size: 0.9rem; font-weight: 700; }
.flow-addr { font-size: 0.72rem; color: var(--muted); font-family: var(--mono); }
.flow-bar-actions { margin-left: auto; display: flex; gap: 0.4rem; align-items: center; }
.flow-bar-actions .btn { text-decoration: none; display: inline-flex; align-items: center; }
.flow-frame {
  flex: 1;
  width: 100%;
  border: none;
  background: #fff;
  min-height: 0;
}
/* 远程桌面（noVNC 内嵌） */
.panel-remote { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.panel-remote.hidden { display: none; }
.panel-remote .flow-frame { background: #1e293b; }
.remote-hint { margin: 0; padding: 0.4rem 1.25rem; background: var(--card); border-top: 1px solid var(--border); }

.panel-placeholder { flex: 1; display: flex; align-items: center; justify-content: center; }
.placeholder-box {
  text-align: center;
  color: var(--muted);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2.5rem 3rem;
  box-shadow: 0 8px 32px rgba(15, 23, 42, 0.06);
}
.placeholder-box .ph-icon {
  width: 76px; height: 76px;
  border-radius: 50%;
  background: #f1f5f9;
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 1rem;
}
.placeholder-box .ph-icon svg { fill: #94a3b8; }
.placeholder-box h2 { margin: 0 0 0.6rem; font-size: 1.15rem; color: var(--text); }
.placeholder-box .ph-tag {
  display: inline-block;
  font-size: 0.78rem; font-weight: 600;
  color: var(--warn);
  background: #fffbeb;
  border: 1px solid #fde68a;
  padding: 0.3rem 0.85rem;
  border-radius: 999px;
}
.placeholder-box p { margin: 0.85rem 0 0; }

.ph-loading { display: flex; flex-direction: column; align-items: center; gap: 1rem; padding: 0.5rem 0; }
.ph-loading p { margin: 0; font-size: 0.92rem; color: var(--muted); }
.ph-spinner {
  width: 46px; height: 46px;
  border-radius: 50%;
  border: 4px solid #e2e8f0;
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

.topology-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(15, 23, 42, 0.08);
  margin-bottom: 1rem;
  overflow: hidden;
}

.topology-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

.topology-head h2 { margin: 0; font-size: 0.95rem; }
.topo-title { display: flex; align-items: center; gap: 0.55rem; }
.title-logo {
  height: 46px;
  width: auto;
  object-fit: contain;
  display: block;
}
.head-right { display: flex; align-items: center; gap: 1rem; }

.view-switch {
  display: inline-flex;
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
}
.view-switch button {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.3rem 0.85rem;
  border-radius: 6px;
  cursor: pointer;
}
.view-switch button.active { background: #fff; color: var(--accent); box-shadow: 0 1px 3px rgba(15,23,42,.1); }

.hidden { display: none !important; }

.overview-view { padding: 1rem 1.1rem 1.25rem; }

.ov-top {
  display: flex;
  align-items: stretch;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.flow-strip {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: stretch;
  gap: 0.3rem;
}
/* 概览的实时画面：放在旋蒸右侧，约 1.2 个模块框宽 */
.cam-slot { width: 23%; flex-shrink: 0; display: flex; align-items: stretch; }
.cam-slot .camera-overlay { width: 100%; align-self: flex-start; }

.mod-card {
  flex: 1;
  min-width: 0;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.55rem 0.5rem;
  transition: all 0.2s;
}
.mod-card.is-active {
  background: #eff6ff;
  border-color: var(--accent);
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.16);
}
.mod-name {
  font-weight: 700;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}
.mod-meta { font-size: 0.66rem; color: var(--muted); margin: 0.2rem 0 0.3rem; font-family: var(--mono); }
.mod-status { font-size: 0.72rem; font-weight: 600; }
.flow-arrow { align-self: center; color: #cbd5e1; font-size: 0.95rem; font-weight: 700; }

.sdot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.sdot.online { background: var(--state-online); }
.sdot.busy { background: var(--state-busy); animation: pulse 1.2s ease-in-out infinite; }
.sdot.offline { background: var(--state-offline); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }
.mod-status.online, .pc-meta .online { color: var(--state-online); }
.mod-status.busy, .pc-meta .busy { color: var(--warn); }
.mod-status.offline, .pc-meta .offline { color: var(--state-offline); }

.overview-grid { display: grid; grid-template-columns: 1fr 1.4fr; gap: 1rem; }
.ov-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.85rem 1rem;
}
.ov-card h4 { margin: 0 0 0.6rem; font-size: 0.82rem; color: var(--muted); }
.cs-body { font-size: 0.85rem; }
.cs-title { font-weight: 700; font-size: 0.95rem; margin-bottom: 0.5rem; color: var(--accent); }
.cs-row { font-size: 0.8rem; color: #334155; padding: 0.15rem 0; font-family: var(--mono); }

.pump-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
.pump-card {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
}
.pc-head { display: flex; align-items: center; justify-content: space-between; font-size: 0.82rem; }
.pc-bar { height: 7px; background: #e2e8f0; border-radius: 4px; overflow: hidden; margin: 0.45rem 0 0.35rem; }
.pc-fill { height: 100%; border-radius: 4px; background: var(--accent); transition: width 0.4s ease; }
.pc-fill.busy { background: var(--warn); }
.pc-fill.offline { background: var(--state-offline); }
.pc-meta { display: flex; justify-content: space-between; font-size: 0.72rem; color: var(--muted); font-family: var(--mono); }

.camera-overlay {
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.35);
}
/* 详图模式：浮在示意图右下角，宽约 1.2 个分区框（分区≈23.8%，×1.2≈28.5%） */
.camera-overlay.as-overlay {
  position: absolute;
  right: 12px;
  bottom: 12px;
  width: 28.5%;
  z-index: 5;
}
.cam-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px;
  font-size: 0.72rem;
  font-weight: 700;
  color: #e2e8f0;
}
.cam-name { font-size: 0.64rem; color: #94a3b8; font-weight: 500; margin-left: 0.35rem; font-family: var(--mono); }
.cam-btn {
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: transparent;
  color: #cbd5e1;
  font-size: 0.66rem;
  padding: 1px 8px;
  border-radius: 5px;
  cursor: pointer;
}
.cam-btn:hover { background: rgba(148, 163, 184, 0.18); }
.camera-wrap {
  position: relative;
  background: #0b1220;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 90px;
}
.camera-wrap img { width: 100%; height: auto; display: none; }
.camera-wrap img.live { display: block; }
.cam-hint { position: absolute; color: #94a3b8; font-size: 0.72rem; }

.legend { display: flex; gap: 0.85rem; font-size: 0.72rem; color: var(--muted); }
.legend .dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}
.dot.online { background: var(--state-online); }
.dot.busy { background: var(--state-busy); }
.dot.offline { background: var(--state-offline); }
.dot.unknown { background: var(--state-unknown); }

.topology-wrap {
  position: relative;
  background: radial-gradient(ellipse at 50% 0%, #f8fafc 0%, #e8eef5 55%, #e2e8f0 100%);
  min-height: 440px;
  padding: 0.5rem 0;
}

#topologySvg { width: 100%; height: auto; display: block; }

.zone-label {
  font-size: 12px;
  font-weight: 700;
  fill: #64748b;
  letter-spacing: 0.08em;
}

.zone-box {
  stroke: #dbeafe;
  stroke-width: 1;
}

.edge-path {
  fill: none;
  stroke: #cbd5e1;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.4;
  vector-effect: non-scaling-stroke;
}
.edge-path.flow {
  stroke-width: 3;
  opacity: 1;
  stroke-dasharray: 8 6;
  animation: flowDash 0.9s linear infinite;
}
@keyframes flowDash {
  from { stroke-dashoffset: 14; }
  to { stroke-dashoffset: 0; }
}
.edges-layer { pointer-events: none; }
.port-badge.active { fill: #2563eb; }
.zone-status { font-size: 11px; font-weight: 700; }
.zone-box.zone-active { filter: drop-shadow(0 0 6px rgba(37, 99, 235, 0.25)); }
.port-label {
  pointer-events: none;
  font-family: var(--mono);
}

.node-group { cursor: pointer; }
.node-group:hover .icon-ring {
  stroke-width: 2.5;
  filter: drop-shadow(0 1px 3px rgba(15, 23, 42, 0.15));
}
.icon-ring { transition: stroke-width 0.15s, filter 0.15s; }
.icon-mat, .icon-pump-pos, .icon-valve-num {
  pointer-events: none;
  font-family: "Segoe UI", "PingFang SC", sans-serif;
}
.node-label {
  font-size: 10px;
  font-weight: 600;
  fill: #1e293b;
  text-anchor: middle;
  pointer-events: none;
}
.node-group:hover .node-label { fill: #0f172a; }
.pump-readout { font-family: var(--mono); }
.port-badge {
  font-size: 8px;
  font-weight: 700;
  fill: #94a3b8;
  pointer-events: none;
}
.node-state {
  font-size: 8px;
  fill: #64748b;
  text-anchor: middle;
  pointer-events: none;
}

.tooltip {
  position: absolute;
  background: #0f172a;
  color: #f8fafc;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  font-size: 0.72rem;
  pointer-events: none;
  z-index: 10;
  max-width: 200px;
}
.tooltip.hidden { display: none; }

.controls-deck {
  display: grid;
  grid-template-columns: 180px 1fr 232px 188px 220px;
  gap: 0.75rem;
}

.deck-col {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.75rem;
  min-height: 200px;
}

.deck-col h3 { margin: 0 0 0.6rem; font-size: 0.82rem; color: var(--muted); }
.deck-col h4.sub { margin: 0.65rem 0 0.35rem; font-size: 0.72rem; color: var(--muted); font-weight: 600; }
.deck-grow { min-height: 200px; }
.deck-log .log { height: 160px; }

/* 实验记录卡片 */
.rec-label {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 0.72rem; color: var(--muted); font-weight: 600;
  margin-bottom: 0.4rem;
}
.rec-add {
  border: 1px solid var(--border); background: var(--accent-soft);
  color: var(--accent); width: 22px; height: 22px; border-radius: 6px;
  font-size: 0.95rem; line-height: 1; cursor: pointer; padding: 0;
}
.rec-add:hover { background: #cfe0fd; }
.reactant-list { display: flex; flex-direction: column; gap: 0.35rem; }
.reactant-empty { font-size: 0.7rem; color: var(--muted); padding: 0.2rem 0; }
.reactant-row { display: grid; grid-template-columns: 1fr 64px 22px; gap: 0.3rem; }
.reactant-row input {
  border: 1px solid var(--border); border-radius: 6px;
  padding: 0.32rem 0.4rem; font-size: 0.74rem; width: 100%;
}
.reactant-row input:focus { outline: none; border-color: var(--accent); }
.reactant-row .rr-mass { text-align: right; }
.reactant-row .rr-del {
  border: 1px solid var(--border); background: #fff; color: var(--muted);
  border-radius: 6px; cursor: pointer; font-size: 0.85rem; line-height: 1; padding: 0;
}
.reactant-row .rr-del:hover { color: var(--danger); border-color: var(--danger); }
.rec-write { width: 100%; margin-top: 0.5rem; }
.rec-note { margin: 0.35rem 0 0; }
.logpath-row { display: flex; gap: 0.3rem; }
.logpath-row input {
  flex: 1; min-width: 0; border: 1px solid var(--border); border-radius: 6px;
  padding: 0.32rem 0.4rem; font-size: 0.7rem; font-family: var(--mono);
}
.logpath-row input:focus { outline: none; border-color: var(--accent); }
.logpath-actions { display: flex; gap: 0.3rem; margin-top: 0.35rem; }
.logpath-actions .btn { flex: 1; }
#logPathHint { margin: 0.35rem 0 0; word-break: break-all; }
#logPathHint.saved { color: var(--ok); }

.muted { color: var(--muted); }
.small { font-size: 0.72rem; }

.recipe-list { max-height: 280px; overflow-y: auto; }
.recipe-item {
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 0.35rem;
  cursor: pointer;
  font-size: 0.8rem;
}
.recipe-item.selected { border-color: var(--accent); background: var(--accent-soft); }
.recipe-item .cat { font-size: 0.65rem; color: var(--accent); font-weight: 600; }

.actions { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.5rem; }
.btn {
  font: inherit;
  font-size: 0.78rem;
  border: none;
  border-radius: 7px;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.ghost { background: #f8fafc; border: 1px solid var(--border); color: var(--text); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.teal { background: var(--teal); color: #fff; grid-column: 1 / -1; }
.btn.warn { background: #d97706; color: #fff; }
.btn.sm { padding: 0.35rem 0.5rem; font-size: 0.72rem; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.reaction-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.5rem;
  font-size: 0.78rem;
}
.reaction-row label { color: var(--muted); }
.reaction-row input {
  width: 64px;
  font: inherit;
  font-size: 0.78rem;
  padding: 0.25rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  text-align: right;
}
.reaction-row .unit { color: var(--muted); }

.operator-hold {
  margin-top: 0.6rem;
  padding: 0.6rem 0.7rem;
  border-radius: 9px;
  background: #fffbeb;
  border: 1px solid #fbbf24;
  box-shadow: 0 2px 10px rgba(217, 119, 6, 0.18);
  animation: holdPulse 1.6s ease-in-out infinite;
}
@keyframes holdPulse {
  0%, 100% { box-shadow: 0 2px 10px rgba(217, 119, 6, 0.18); }
  50% { box-shadow: 0 2px 16px rgba(217, 119, 6, 0.42); }
}
.operator-hold .oh-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: #b45309;
}
.operator-hold .oh-prompt {
  margin: 0.3rem 0 0.5rem;
  font-size: 0.78rem;
  color: var(--text);
  line-height: 1.4;
}
.operator-hold .oh-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }

.step-preview .sp-line {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: center;
  padding: 1px 4px;
  border-radius: 4px;
  cursor: pointer;
}
.step-preview .sp-line:hover { background: #f1f5f9; }
.step-preview .sp-eta { color: var(--muted); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.step-preview .sp-section { color: var(--accent); font-weight: 600; margin-top: 0.2rem; cursor: default; }
.step-preview .sp-section:hover { background: transparent; }
.step-preview .sp-hold { color: #b45309; font-weight: 600; }
.step-preview .sp-hold .sp-eta { color: #b45309; }

/* 当前正在运行的步骤：唯一的强高亮 */
.step-preview .sp-current {
  background: #dbeafe;
  outline: 2px solid var(--accent);
  font-weight: 700;
  color: #1e3a8a;
}
.step-preview .sp-current .sp-eta { color: #1e3a8a; }

/* 用户选定的起跑步骤（仅未运行时） */
.step-preview .sp-start {
  background: #ecfdf5;
  box-shadow: inset 3px 0 0 #10b981;
}
.step-preview .sp-startmark {
  background: #10b981;
  color: #fff;
  font-size: 0.62rem;
  padding: 0 5px;
  border-radius: 8px;
  margin-right: 5px;
  flex-shrink: 0;
}

.start-hint {
  margin-top: 0.4rem;
  font-size: 0.72rem;
  color: #047857;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: 6px;
  padding: 0.35rem 0.5rem;
}
.link-btn {
  border: none;
  background: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.72rem;
  text-decoration: underline;
  padding: 0 0.2rem;
}

.r-eta { font-size: 0.68rem; color: var(--muted); margin-top: 0.15rem; }
.recipe-item.selected .r-eta { color: rgba(255, 255, 255, 0.85); }

.eta-summary { margin-top: 0.5rem; }
.eta-summary:empty { margin-top: 0; }

.timing-panel {
  margin-top: 0.45rem;
  padding: 0.45rem 0.55rem;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.timing-panel.hidden { display: none; }
.timing-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}
.timing-title { font-size: 0.78rem; font-weight: 600; color: var(--text); }
.timing-steps { max-height: 120px; overflow-y: auto; }
.timing-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.35rem 0.5rem;
  padding: 0.15rem 0;
  border-bottom: 1px dashed #e2e8f0;
  align-items: center;
}
.timing-row:last-child { border-bottom: none; }
.timing-row.current { color: var(--accent); font-weight: 600; }
.timing-row.slow .timing-act { color: #b45309; }
.timing-row.fast .timing-act { color: #047857; }
.timing-lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.timing-act { font-variant-numeric: tabular-nums; }
.timing-est { color: var(--muted); font-variant-numeric: tabular-nums; }
.eta-total {
  font-size: 0.78rem;
  color: var(--text);
  padding: 0.4rem 0.55rem;
  background: #f1f5f9;
  border-radius: 7px;
}
.eta-total b { color: var(--accent); font-size: 0.86rem; }
.eta-note { color: var(--muted); font-size: 0.66rem; font-weight: 400; }
.eta-holds {
  margin-top: 0.45rem;
  padding: 0.45rem 0.55rem;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 7px;
}
.eta-h-title { font-size: 0.74rem; font-weight: 700; color: #b45309; }
.eta-holds ul { margin: 0.3rem 0 0.25rem; padding-left: 1.1rem; }
.eta-holds li { font-size: 0.74rem; line-height: 1.6; }
.eta-holds li b { color: #b45309; }
.eta-holds .eta-note { display: block; margin-top: 0.2rem; line-height: 1.35; }

.btn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.35rem; }

.progress-bar {
  height: 5px;
  background: #e2e8f0;
  border-radius: 3px;
  overflow: hidden;
}
#progressFill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--teal));
  transition: width 0.3s;
}

.progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.run-state {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 10px;
  background: #dcfce7;
  color: #166534;
  flex-shrink: 0;
}
.run-state.paused { background: #fef3c7; color: #92400e; }
.run-state.stopped { background: #fee2e2; color: #991b1b; }
.run-state.done { background: #dbeafe; color: #1e40af; }

.step-progress { margin-top: 0.45rem; }
.progress-bar.sub { height: 4px; background: #eef2f7; }
#stepProgressFill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #38bdf8, #22c55e);
  transition: width 0.5s linear;
}
.step-progress.paused #stepProgressFill {
  background: repeating-linear-gradient(45deg, #f59e0b, #f59e0b 6px, #fbbf24 6px, #fbbf24 12px);
}
.sp-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.2rem;
  font-size: 0.7rem;
  color: var(--muted);
}
.sp-meta .sp-loop { color: var(--accent); font-weight: 600; flex-shrink: 0; }

.step-preview {
  margin-top: 0.5rem;
  font-size: 0.72rem;
  max-height: 220px;
  overflow-y: auto;
  line-height: 1.45;
}

.manual-compact { max-height: 100px; overflow-y: auto; font-size: 0.72rem; }
.manual-compact .grp { margin-bottom: 0.4rem; }
.manual-compact .grp-name { color: var(--muted); margin-bottom: 0.2rem; }
.manual-compact button {
  margin: 0 0.2rem 0.2rem 0;
  padding: 0.2rem 0.45rem;
  font-size: 0.68rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: #f8fafc;
  cursor: pointer;
}

.log {
  font-family: var(--mono);
  font-size: 0.68rem;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem;
  margin: 0;
  overflow-y: auto;
  white-space: pre-wrap;
}

/* ===== 自动称量模块 ===== */
.panel-weighing { flex: 1; padding: 1rem 1.25rem 1.5rem; overflow: auto; }
.panel-weighing.hidden { display: none; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 6px 24px rgba(15, 23, 42, 0.06);
}

/* 顶部状态条 */
.wm-statbar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.85rem;
  margin-bottom: 1rem;
}
.wm-stat {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.85rem 1rem;
  box-shadow: 0 6px 24px rgba(15, 23, 42, 0.06);
}
.wm-ic {
  width: 42px; height: 42px;
  border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.wm-ic svg { fill: #fff; }
.ic-device { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.ic-action { background: linear-gradient(135deg, #f59e0b, #d97706); }
.ic-progress { background: linear-gradient(135deg, #10b981, #0d9488); }
.ic-tube { background: linear-gradient(135deg, #a855f7, #7c3aed); }
.wm-stat-txt { display: flex; flex-direction: column; min-width: 0; }
.wm-stat-txt span { font-size: 0.7rem; color: var(--muted); }
.wm-stat-txt b { font-size: 1.02rem; color: var(--text); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 主网格：可视化 + 操作 */
.wm-grid {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 1rem;
  align-items: start;
}

/* 可视化 */
.wm-viz { padding: 1rem 1.2rem 1.4rem; }
.wm-viz-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.1rem;
}
.wm-viz-head h2 { margin: 0; font-size: 1rem; display: flex; align-items: center; gap: 0.55rem; }
.wm-legend { display: flex; gap: 0.9rem; font-size: 0.74rem; color: var(--muted); }
.wm-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.wdot.plan { background: #bfdbfe; border: 1px solid #60a5fa; }
.wdot.active { background: var(--warn); }
.wdot.done { background: #16a34a; }

/* 料槽 / 称量头 */
.wm-rack {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: linear-gradient(180deg, #f8fafc, #eef2f7);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.9rem 1.1rem;
  margin-bottom: 1.2rem;
}
.wm-rack-cap { font-size: 0.74rem; color: var(--muted); writing-mode: vertical-rl; letter-spacing: 0.15em; }
.rack-tubes { display: flex; gap: 0.85rem; flex: 1; }
.tube {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  transition: transform 0.25s;
}
.tube-cap {
  width: 34px; height: 8px;
  border-radius: 4px 4px 2px 2px;
  background: #cbd5e1;
}
.tube-body {
  width: 30px; height: 56px;
  border-radius: 5px 5px 9px 9px;
  background: linear-gradient(180deg, #f1f5f9, #e2e8f0);
  border: 1.5px solid #cbd5e1;
  display: flex; align-items: flex-end; justify-content: center;
  position: relative;
  overflow: hidden;
}
.tube-body::after {
  content: "";
  position: absolute; left: 0; right: 0; bottom: 0;
  height: 38%;
  background: var(--tc, #94a3b8);
  opacity: 0.18;
}
.tube-no { font-size: 0.82rem; font-weight: 800; color: #64748b; position: relative; z-index: 1; margin-bottom: 4px; }
.tube-st { font-size: 0.68rem; color: var(--muted); }
.tube.planned .tube-cap { background: var(--tc); }
.tube.planned .tube-body { border-color: var(--tc); }
.tube.planned .tube-no { color: var(--tc); }
.tube.planned .tube-st { color: var(--tc); font-weight: 600; }
.tube.held { transform: translateY(-10px); }
.tube.held .tube-cap { background: var(--warn); }
.tube.held .tube-body {
  border-color: var(--warn);
  box-shadow: 0 8px 18px rgba(217, 119, 6, 0.3);
}
.tube.held .tube-body::after { background: var(--warn); opacity: 0.32; height: 60%; }
.tube.held .tube-no { color: var(--warn); }
.tube.held .tube-st { color: var(--warn); font-weight: 700; }

.wm-head {
  display: flex; align-items: center; gap: 0.5rem;
  font-size: 0.78rem; color: #334155;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  min-width: 150px;
}
.wm-head .hb-spinner {
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid #cbd5e1; border-top-color: transparent;
  flex-shrink: 0;
}
.wm-head.active { background: #fffbeb; border-color: #fde68a; color: var(--warn); font-weight: 600; }
.wm-head.active .hb-spinner { border-color: var(--warn); border-top-color: transparent; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 96 孔板 */
.wm-plate-zone { display: flex; justify-content: center; }
.wm-plate-frame {
  background: linear-gradient(160deg, #fafbfc, #eceff4);
  border: 1px solid #d8dee8;
  border-radius: 14px;
  padding: 0.9rem 1rem 1rem;
  box-shadow: inset 0 1px 0 #fff, 0 2px 10px rgba(15, 23, 42, 0.05);
  width: 100%;
  max-width: 760px;
}
.plate96 {
  display: grid;
  grid-template-columns: 22px repeat(12, 1fr);
  gap: 6px;
}
.plate-corner {}
.plate-h, .plate-rh {
  font-size: 0.68rem;
  color: #94a3b8;
  text-align: center;
  align-self: center;
  font-family: var(--mono);
  font-weight: 700;
}
.wcell {
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffffff, #e9eef5);
  border: 1px solid #d3dae6;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.08);
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}
.wval { font-size: 0.52rem; font-family: var(--mono); font-weight: 700; line-height: 1; }
.wcell.w-planned {
  background: radial-gradient(circle at 35% 30%, #eff6ff, #bfdbfe);
  border-color: #60a5fa;
}
.wcell.w-pending {
  background: radial-gradient(circle at 35% 30%, #eff6ff, #bfdbfe);
  border-color: #3b82f6;
}
.wcell.w-active {
  background: radial-gradient(circle at 35% 30%, #fde68a, var(--warn));
  border-color: var(--warn);
  color: #7c2d12;
  box-shadow: 0 0 0 4px rgba(217, 119, 6, 0.22);
  animation: pulse 1.1s ease-in-out infinite;
  transform: scale(1.08);
}
.wcell.w-done {
  background: radial-gradient(circle at 35% 30%, #4ade80, #16a34a);
  border-color: #15803d;
  color: #fff;
}
.wcell.w-head { outline: 2px solid #1d4ed8; outline-offset: 1px; }

/* 操作面板 */
.wm-ops { display: flex; flex-direction: column; gap: 0.85rem; }
.wm-ops .card { padding: 0.9rem 1rem; }
.wm-ops h3 {
  margin: 0 0 0.7rem; font-size: 0.86rem; color: var(--text);
  display: flex; align-items: center; gap: 0.5rem;
}
.step-no {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--accent); color: #fff;
  font-size: 0.72rem; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}

/* 连接卡 */
.op-conn-row { display: flex; align-items: center; gap: 0.6rem; }
.conn-dot { width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0; }
.conn-dot.off { background: var(--state-offline); }
.conn-dot.on { background: var(--state-online); }
.conn-dot.busy { background: var(--warn); animation: pulse 1.2s ease-in-out infinite; }
.op-conn-txt { flex: 1; min-width: 0; line-height: 1.2; }
.op-conn-txt b { font-size: 0.88rem; }
.op-conn-txt small { display: block; font-size: 0.68rem; color: var(--muted); font-family: var(--mono); }
.op-progress { margin-top: 0.75rem; }
.op-progress .progress-bar { height: 7px; }
.op-progress #massProgressFill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--teal));
  transition: width 0.35s ease;
}
.op-progress p { margin: 0.4rem 0 0; }

/* 任务配置 */
.build-field { margin-bottom: 0.7rem; }
.build-field > label {
  display: block; font-size: 0.72rem; color: var(--muted); margin-bottom: 0.35rem;
}
.tube-pills { display: flex; gap: 0.4rem; }
.tube-pill {
  flex: 1;
  border: 1.5px solid var(--border);
  background: #f8fafc;
  border-radius: 9px;
  padding: 0.45rem 0;
  font-size: 0.9rem; font-weight: 700;
  color: #64748b;
  cursor: pointer;
  transition: all 0.15s;
}
.tube-pill:hover { border-color: #93c5fd; }
.tube-pill.on {
  background: var(--accent); border-color: var(--accent); color: #fff;
  box-shadow: 0 3px 10px rgba(37, 99, 235, 0.3);
}
.well-pick { display: flex; align-items: center; gap: 0.45rem; }
.well-pick select {
  flex: 1; font: inherit; font-size: 0.85rem;
  padding: 0.4rem 0.5rem; border: 1px solid var(--border);
  border-radius: 8px; background: #fff;
}
.wp-x { font-size: 0.68rem; color: var(--muted); }
.mass-input { display: flex; align-items: center; gap: 0.4rem; }
.mass-input input {
  flex: 1; font: inherit; font-size: 0.85rem;
  padding: 0.4rem 0.55rem; border: 1px solid var(--border);
  border-radius: 8px; background: #fff;
}
.mi-unit { font-size: 0.78rem; color: var(--muted); }
.build-actions { display: flex; gap: 0.5rem; margin-top: 0.4rem; }
.build-actions .btn { flex: 1; }

/* 任务清单 */
.op-list-head { display: flex; align-items: center; justify-content: space-between; }
.op-list-head h3 { margin: 0; }
.chip {
  font-size: 0.7rem; font-weight: 700;
  background: var(--accent-soft); color: var(--accent);
  padding: 0.15rem 0.55rem; border-radius: 999px;
}
.task-list { max-height: 220px; overflow-y: auto; margin-top: 0.7rem; }
.task-empty { color: var(--muted); font-size: 0.74rem; text-align: center; padding: 1.2rem 0.5rem; line-height: 1.5; }
.task-row {
  display: grid;
  grid-template-columns: 44px 48px 1fr 26px;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 0.35rem;
  font-size: 0.78rem;
  background: #fff;
}
.tr-tube { text-align: center; font-weight: 700; border-radius: 6px; padding: 0.12rem 0; font-size: 0.7rem; }
.tr-well { font-family: var(--mono); font-weight: 700; }
.tr-mass { font-family: var(--mono); color: #334155; text-align: right; }
.tr-mass small { color: var(--muted); margin-left: 2px; }
.tr-del {
  border: none; background: #fef2f2; color: var(--danger);
  border-radius: 6px; cursor: pointer; font-size: 0.95rem; line-height: 1; padding: 3px 0;
}
.tr-del:hover { background: #fecaca; }

/* 执行 */
.run-actions { display: flex; gap: 0.5rem; }
.btn.run {
  flex: 1;
  background: linear-gradient(135deg, #16a34a, #0d9488);
  color: #fff; font-weight: 700; font-size: 0.85rem;
  padding: 0.6rem 0.75rem;
  box-shadow: 0 4px 14px rgba(22, 163, 74, 0.28);
}
.btn.run:disabled { background: #cbd5e1; box-shadow: none; }
.op-run .btn.danger { padding: 0.6rem 0.9rem; }

/* 手动 / 日志 */
.op-manual { padding: 0 !important; }
.op-manual summary {
  list-style: none; cursor: pointer;
  padding: 0.75rem 1rem; font-size: 0.82rem; font-weight: 600; color: var(--muted);
}
.op-manual summary::-webkit-details-marker { display: none; }
.op-manual summary::before { content: "▸ "; }
.op-manual[open] summary::before { content: "▾ "; }
.manual-body { padding: 0 1rem 1rem; }
.manual-row { display: flex; gap: 0.4rem; margin-bottom: 0.5rem; }
.manual-row select, .manual-row input {
  flex: 1; min-width: 0; font: inherit; font-size: 0.76rem;
  padding: 0.32rem 0.45rem; border: 1px solid var(--border); border-radius: 6px; background: #fff;
}
.manual-body .log { height: 120px; margin-top: 0.5rem; }

@media (max-width: 1200px) {
  .wm-grid { grid-template-columns: 1fr; }
  .wm-statbar { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 1366px) {
  .controls-deck { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 1100px) {
  .controls-deck { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 768px) {
  .controls-deck { grid-template-columns: 1fr; }
  .sidebar { width: 56px; }
  .brand div, .nav-modules li span:not(.tag) { display: none; }
}
