/* ===== 三文鱼品质数字孪生 · 全屏品质驾驶舱 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --bg: #eef1f4;
  --panel: #ffffff;
  --border: #dde3e8;
  --text: #2b3540;
  --muted: #8592a0;
  --accent: #0f766e;
  --fresh: #2fa36b;
  --warning: #e6a23c;
  --spoiled: #d64545;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}
html, body { height: 100%; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 12px; overflow: hidden;
}
.mono { font-family: var(--mono); }
.strong { font-weight: 700; }
.small { font-size: 10px; }
.muted { color: var(--muted); }

.page {
  display: grid; height: 100vh;
  grid-template-rows: 54px minmax(0, 1fr) 300px;
  gap: 6px; padding: 6px;
}

/* ---------- 顶部状态栏 ---------- */
.topbar {
  display: flex; align-items: center; gap: 18px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 6px; padding: 0 14px; overflow: hidden;
}
.brand { margin-right: 8px; }
.brand-title { font-size: 15px; font-weight: 700; letter-spacing: 1px; }
.brand-sub { font-size: 9px; color: var(--muted); letter-spacing: 0.5px; }
.top-item { display: flex; flex-direction: column; line-height: 1.25; }
.top-item label { font-size: 9px; color: var(--muted); }
.top-item span { font-size: 13px; }
.top-item select {
  font-size: 12px; padding: 2px 4px; border: 1px solid var(--border);
  border-radius: 4px; background: #fff; max-width: 170px;
}
#clock { color: var(--muted); }

.badge {
  display: inline-block; padding: 2px 10px; border-radius: 10px;
  font-size: 11px; font-weight: 600; color: #fff; background: #9aa7b2;
}
.badge.lv-fresh { background: var(--fresh); }
.badge.lv-warning { background: var(--warning); }
.badge.lv-spoiled { background: var(--spoiled); }
.badge.lv-unknown { background: #9aa7b2; }

/* ---------- 主区三列 ---------- */
.main {
  display: grid; grid-template-columns: minmax(0, 44%) minmax(0, 1fr) 300px;
  gap: 6px; min-height: 0;
}
.panel {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 6px; display: flex; flex-direction: column; min-height: 0; overflow: hidden;
}
.panel-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 7px 10px; border-bottom: 1px solid var(--border); flex: none;
}
.panel-title { font-size: 12px; font-weight: 700; }
.panel-sub { font-size: 10px; color: var(--muted); }

/* 左：三维 */
.twin-canvas { flex: 1; min-height: 0; position: relative; }
.twin-canvas canvas { display: block; }
.twin-fallback {
  position: absolute; inset: 0; display: flex; align-items: center;
  justify-content: center; color: var(--muted); font-size: 12px; text-align: center;
}
.visual-bars { flex: none; padding: 6px 10px 8px; border-top: 1px solid var(--border); }
.vb { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.vb label { width: 60px; color: var(--muted); font-size: 10px; flex: none; }
.vb-track { flex: 1; height: 7px; background: #edf0f3; border-radius: 4px; overflow: hidden; }
.vb-fill { height: 100%; width: 0%; border-radius: 4px; transition: width 0.6s; }
.vb span { width: 34px; text-align: right; font-size: 10px; }
.c-spoil { background: #8a5a44; }
.c-ox { background: #d9a03f; }
.c-mic { background: #d64545; }
.c-drip { background: #4d9de0; }
.c-tis { background: #9b59b6; }

/* 中：监控 + 日志 */
.center-col { display: grid; grid-template-rows: minmax(0, 1fr) minmax(0, 1fr); gap: 6px; min-height: 0; }
.chan-grid {
  flex: 1; display: grid; grid-template-columns: 1fr 1fr;
  gap: 4px 12px; padding: 10px 12px; align-content: start; overflow: auto;
}
.chan { display: flex; justify-content: space-between; border-bottom: 1px dashed #edf0f3; padding: 3px 0; }
.chan label { color: var(--muted); }
.chan span { font-size: 13px; font-weight: 600; }
.ws-url { padding: 4px 10px; color: var(--muted); font-size: 10px; word-break: break-all; flex: none; }
.frame-log {
  flex: 1; overflow-y: auto; padding: 4px 10px 8px; font-size: 10px; line-height: 1.6;
}
.frame-log .lg-ok { color: var(--accent); }
.frame-log .lg-warn { color: var(--warning); }
.frame-log .lg-bad { color: var(--spoiled); }
.frame-log .lg-sys { color: var(--muted); }

/* 右：边栏页签 */
.sidebar { min-height: 0; }
.tabs { display: flex; flex: none; border-bottom: 1px solid var(--border); }
.tab {
  flex: 1; padding: 8px 0; border: none; background: #f6f8fa; cursor: pointer;
  font-size: 11px; color: var(--muted); border-right: 1px solid var(--border);
}
.tab:last-child { border-right: none; }
.tab.active { background: #fff; color: var(--accent); font-weight: 700; box-shadow: inset 0 -2px 0 var(--accent); }
.tab-page { display: none; flex: 1; overflow-y: auto; padding: 8px 10px; }
.tab-page.active { display: block; }
.side-block { margin-bottom: 12px; }
.side-title {
  font-size: 11px; font-weight: 700; color: var(--accent);
  border-left: 3px solid var(--accent); padding-left: 6px; margin-bottom: 6px;
}
.kv { display: flex; justify-content: space-between; align-items: center; padding: 3px 0; border-bottom: 1px dashed #edf0f3; }
.kv label { color: var(--muted); }
.mini-chart { height: 110px; }
.alert-list { list-style: none; }
.alert-list li { padding: 4px 6px; border-radius: 4px; margin-bottom: 4px; background: #fdf3e7; color: #a05a00; }
.alert-list li.ok { background: #e9f7f0; color: var(--fresh); }
.alert-list li.bad { background: #fdeaea; color: var(--spoiled); }
.science p { margin-bottom: 6px; line-height: 1.5; color: #4c5866; }

/* 表单与按钮 */
.form .frow { display: flex; align-items: center; margin-bottom: 6px; gap: 6px; }
.form .frow label { width: 76px; flex: none; color: var(--muted); }
.form .frow input {
  flex: 1; min-width: 0; padding: 4px 6px; border: 1px solid var(--border);
  border-radius: 4px; font-size: 12px;
}
.btn {
  padding: 5px 10px; border: 1px solid var(--border); border-radius: 4px;
  background: #fff; cursor: pointer; font-size: 12px; color: var(--text);
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; width: 100%; }
.btn.warn { color: var(--spoiled); border-color: var(--spoiled); }
.action-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 8px; }
.advice {
  background: #f6f8fa; border: 1px solid var(--border); border-radius: 4px;
  padding: 8px; line-height: 1.6;
}
.batch-list .bitem {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px; border: 1px solid var(--border); border-radius: 4px; margin-bottom: 5px; cursor: pointer;
}
.batch-list .bitem:hover { border-color: var(--accent); }
.batch-list .bitem.current { border-color: var(--accent); background: #f0faf8; }

/* 迷你表格 */
.mini-table-wrap { overflow: auto; max-height: 220px; }
.mini-table { width: 100%; border-collapse: collapse; font-size: 10px; }
.mini-table th, .mini-table td { border: 1px solid #edf0f3; padding: 3px 5px; text-align: left; white-space: nowrap; }
.mini-table th { background: #f6f8fa; color: var(--muted); position: sticky; top: 0; }

/* ---------- 底部图表区 ---------- */
.bottom {
  display: grid; gap: 6px; min-height: 0;
  grid-template-columns: minmax(0, 27%) minmax(0, 14%) minmax(0, 19%) minmax(0, 18%) minmax(0, 22%);
}
.chart { flex: 1; min-height: 0; }
.matrix-wrap { flex: 1; overflow: auto; padding: 8px; }
.matrix-table { width: 100%; border-collapse: collapse; font-size: 10px; text-align: center; }
.matrix-table th, .matrix-table td { border: 1px solid var(--border); padding: 4px 3px; }
.matrix-table th { background: #f6f8fa; color: var(--muted); }
.cell-fresh { background: #e9f7f0; color: var(--fresh); font-weight: 600; }
.cell-warning { background: #fdf3e7; color: #a05a00; font-weight: 600; }
.cell-spoiled { background: #fdeaea; color: var(--spoiled); font-weight: 600; }
.core-eval { padding: 6px 10px; }
.ce-row { display: flex; justify-content: space-between; align-items: center; padding: 2px 0; border-bottom: 1px dashed #edf0f3; }
.ce-row .ce-name { color: var(--muted); }
.ce-row .ce-val { font-family: var(--mono); font-weight: 600; }
.ce-tag { font-size: 9px; padding: 1px 6px; border-radius: 8px; color: #fff; margin-left: 6px; }
.shelf-panel { padding: 6px 10px 10px; font-size: 11px; line-height: 1.7; }
.shelf-panel .rsl-big { font-size: 20px; font-weight: 700; font-family: var(--mono); }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: #c8d0d8; border-radius: 3px; }

/* ================= 响应式：平板与手机 ================= */
@media (max-width: 1200px) {
  .bottom { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 992px) {
  html, body { height: auto; }
  body { overflow: auto; font-size: 13px; }
  .page { display: flex; flex-direction: column; height: auto; min-height: 100vh; gap: 8px; padding: 8px; }

  /* 顶栏换行，品牌独占一行 */
  .topbar { flex-wrap: wrap; gap: 8px 16px; padding: 8px 12px; }
  .brand { width: 100%; margin-right: 0; }
  .top-item span { font-size: 14px; }
  .top-item select { max-width: 220px; font-size: 14px; padding: 4px 6px; }

  /* 主区单列堆叠：三维 → 实时监控 → 通讯帧 → 边栏页签 */
  .main { display: flex; flex-direction: column; gap: 8px; }
  .twin-canvas { flex: none; height: 340px; }
  .center-col { display: flex; flex-direction: column; gap: 8px; }
  .frame-log { flex: none; max-height: 180px; overflow-y: auto; }
  .tab-page { flex: none; overflow: visible; }

  /* 触控优化 */
  .tab { padding: 10px 0; font-size: 13px; }
  .btn { padding: 8px 12px; font-size: 13px; }
  .form .frow input { padding: 8px; font-size: 16px; }

  /* 底部图表两列，固定高度供 ECharts 计算 */
  .bottom { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chart { flex: none; height: 240px; }
  .matrix-wrap { flex: none; max-height: 260px; }
}

@media (max-width: 640px) {
  .bottom { grid-template-columns: minmax(0, 1fr); }
  .twin-canvas { height: 300px; }
  .chart { height: 220px; }
  .brand-title { font-size: 14px; }
  .top-item select { max-width: 150px; }
}
