:root {
  color-scheme: light;
  --ink: #16202a;
  --muted: #60717f;
  --line: #d8e0e8;
  --panel: rgba(255, 255, 255, 0.94);
  --surface: #f4f7f9;
  --control: #174d7c;
  --measure: #7b4bb2;
  --temp: #c9372c;
  --pressure: #1d6fc0;
  --velocity: #118964;
  --shadow: 0 16px 38px rgba(25, 40, 55, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: linear-gradient(180deg, rgba(230, 237, 243, 0.9), rgba(246, 248, 250, 0.98)), var(--surface);
  color: var(--ink);
  font-family: "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", "Segoe UI", system-ui, sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  padding: 18px;
}

.topbar,
.workbench,
.run-strip,
.control-grid,
.maps-grid,
.stage-head,
.view-tabs,
.pipeline,
.readout-grid {
  display: grid;
  gap: 12px;
}

.topbar {
  grid-template-columns: minmax(520px, 1fr) auto;
  align-items: center;
  margin-bottom: 14px;
}

.eyebrow {
  margin: 0 0 5px;
  color: #496270;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 28px;
  line-height: 1.15;
}

h2 {
  margin-bottom: 0;
  font-size: 19px;
}

h3 {
  margin-bottom: 9px;
  color: #243747;
  font-size: 14px;
}

.run-strip {
  grid-template-columns: repeat(4, 112px) 70px;
}

.run-strip > div,
.panel,
.map-card,
.pipe-node,
.readout-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.run-strip > div {
  min-height: 58px;
  padding: 9px 11px;
}

.run-strip span,
label span,
.map-card header span,
.pipe-node span,
.readout-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.run-strip strong {
  display: block;
  margin-top: 4px;
  font-size: 17px;
}

.primary-button {
  min-height: 58px;
  border: 0;
  border-radius: 8px;
  background: var(--control);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

.workbench {
  grid-template-columns: 330px minmax(720px, 1fr) 330px;
  align-items: start;
}

.panel {
  padding: 15px;
}

.panel-heading {
  margin-bottom: 12px;
}

.control-block {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  margin-top: 12px;
}

.control-block:first-of-type {
  border-top: 0;
  padding-top: 0;
  margin-top: 0;
}

.control-grid {
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

label {
  display: block;
  margin-bottom: 0;
}

input,
select {
  width: 100%;
  height: 32px;
  margin-top: 5px;
  border: 1px solid #c8d3dc;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 0 8px;
  outline: none;
}

select {
  padding-right: 4px;
}

input:focus,
select:focus {
  border-color: var(--control);
  box-shadow: 0 0 0 3px rgba(23, 77, 124, 0.14);
}

.center-stage {
  min-width: 0;
}

.stage-head {
  grid-template-columns: 1fr auto;
  align-items: end;
  margin-bottom: 12px;
}

.view-tabs {
  grid-template-columns: repeat(5, 64px);
  gap: 6px;
}

.view-tabs button {
  height: 34px;
  border: 1px solid #c8d3dc;
  border-radius: 6px;
  background: #fff;
  color: #415364;
  cursor: pointer;
}

.view-tabs button.active {
  border-color: var(--control);
  background: var(--control);
  color: #fff;
  font-weight: 800;
}

.maps-grid {
  grid-template-columns: 1fr 1fr;
}

.map-card {
  overflow: hidden;
}

.map-card header {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  min-height: 55px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.map-card header strong {
  display: block;
  margin-top: 3px;
  font-size: 16px;
}

.map-card header em {
  font-style: normal;
  font-size: 18px;
  font-weight: 900;
}

.map-frame,
.photo-frame {
  position: relative;
  height: 270px;
  overflow: hidden;
  background: #17212b;
}

.photo-frame img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: contrast(1.1) saturate(1.12) brightness(0.95);
}

.map-frame canvas,
.photo-frame canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.camera-label {
  position: absolute;
  border: 1px solid rgba(57, 255, 118, 0.85);
  border-radius: 4px;
  background: rgba(3, 22, 12, 0.68);
  color: #d7ffe2;
  padding: 4px 7px;
  font-size: 11px;
  font-weight: 900;
}

.cam-a {
  left: 7%;
  bottom: 22%;
}

.cam-b {
  left: 16%;
  bottom: 35%;
}

.cam-c {
  left: 4%;
  bottom: 48%;
}

.rig-label {
  right: 7%;
  top: 18%;
}

.scale {
  position: absolute;
  right: 11px;
  bottom: 11px;
  display: flex;
  justify-content: space-between;
  width: 150px;
  height: 24px;
  padding: 5px 7px;
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: 5px;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.temp-scale {
  background: linear-gradient(90deg, #243b8f, #20a3a3, #f3d35b, #bf2f2f);
}

.pressure-scale {
  background: linear-gradient(90deg, #edf6ff, #77b7e5, #1d6fc0, #18316f);
}

.velocity-scale {
  background: linear-gradient(90deg, #eef8ef, #79c86d, #f1c94a, #ba3c2c);
}

.pipeline {
  grid-template-columns: repeat(4, 1fr);
  margin-top: 12px;
}

.pipe-node {
  min-height: 70px;
  padding: 12px;
  border-top: 4px solid var(--control);
}

.pipe-node.measure {
  border-top-color: var(--measure);
}

.pipe-node.process {
  border-top-color: var(--pressure);
}

.pipe-node.output {
  border-top-color: var(--velocity);
}

.pipe-node strong {
  display: block;
  margin-top: 5px;
  color: #243747;
  font-size: 13px;
}

.readout-block {
  padding: 13px;
  margin-bottom: 12px;
}

.readout-grid {
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.readout-grid > div {
  min-height: 52px;
  padding: 8px;
  border: 1px solid #e0e7ee;
  border-radius: 7px;
  background: #f8fafc;
}

.readout-grid strong {
  display: block;
  margin-top: 4px;
  font-size: 16px;
}

.sparkline {
  width: 100%;
  height: 76px;
  margin-top: 10px;
  border-radius: 6px;
  background: #f3f7f9;
}

.quality-note {
  margin: 10px 0 0;
  padding: 8px 10px;
  border-radius: 6px;
  background: #edf7f3;
  color: #23664d;
  font-size: 13px;
  font-weight: 800;
}

body[data-layer="camera"] .map-card:not([data-map="camera"]),
body[data-layer="temperature"] .map-card:not([data-map="temperature"]),
body[data-layer="pressure"] .map-card:not([data-map="pressure"]),
body[data-layer="tomo"] .map-card:not([data-map="tomo"]) {
  display: none;
}

body[data-layer="camera"] .map-card,
body[data-layer="temperature"] .map-card,
body[data-layer="pressure"] .map-card,
body[data-layer="tomo"] .map-card {
  grid-column: 1 / -1;
}

body[data-layer="camera"] .photo-frame,
body[data-layer="temperature"] .map-frame,
body[data-layer="pressure"] .map-frame,
body[data-layer="tomo"] .map-frame {
  height: 620px;
}

@media (max-width: 1460px) {
  .workbench {
    grid-template-columns: 310px minmax(650px, 1fr) 310px;
  }

  .map-frame,
  .photo-frame {
    height: 235px;
  }
}

@media (max-width: 1180px) {
  .topbar,
  .workbench,
  .stage-head {
    grid-template-columns: 1fr;
  }

  .run-strip {
    grid-template-columns: repeat(5, minmax(92px, 1fr));
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 12px;
  }

  h1 {
    font-size: 22px;
  }

  .run-strip,
  .control-grid,
  .maps-grid,
  .pipeline,
  .readout-grid,
  .view-tabs {
    grid-template-columns: 1fr;
  }

  .map-frame,
  .photo-frame {
    height: 250px;
  }
}
