:root {
  --ink: #102033;
  --muted: #627287;
  --paper: #eef6f2;
  --panel: #ffffff;
  --line: #d7e5ee;
  --blue: #0b63b6;
  --cyan: #12b7cf;
  --green: #18a36c;
  --amber: #f0a31a;
  --field: #75b843;
  --water: #17a6d8;
  --trace: #5967e8;
  --orange: #e76f2d;
  --violet: #6657e8;
  --red: #d94b4b;
  --active-color: var(--cyan);
  --active-glow: rgba(18, 183, 207, 0.36);
  --shadow: 0 18px 42px rgba(16, 32, 51, 0.14);
  --radius: 8px;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(16, 32, 51, 0.045) 1px, transparent 1px),
    linear-gradient(rgba(16, 32, 51, 0.045) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
  font-family:
    "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", Inter, Arial,
    sans-serif;
}

button,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: var(--radius);
  background: #e9f2f8;
  color: var(--ink);
  cursor: pointer;
  font-weight: 900;
  transition:
    transform 150ms ease,
    box-shadow 150ms ease,
    background 150ms ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(16, 32, 51, 0.12);
}

button:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(240, 163, 26, 0.56);
  outline-offset: 2px;
}

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

.app-shell {
  width: min(1740px, calc(100% - 32px));
  margin: 0 auto;
  padding: 20px 0 28px;
}

.topbar,
.notice-strip,
.view-switcher,
.scene-card,
.operator-panel,
.step-dock {
  border: 1px solid rgba(16, 32, 51, 0.1);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.topbar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  padding: 16px 18px;
  background: linear-gradient(135deg, #ffffff 0%, #f4fbf7 58%, #eef9ed 100%);
  border-color: rgba(11, 99, 182, 0.2);
}

.logo-slot {
  display: grid;
  width: 84px;
  height: 64px;
  place-items: center;
  border: 2px dashed rgba(11, 99, 182, 0.72);
  border-radius: var(--radius);
  color: var(--blue);
  background: rgba(255, 255, 255, 0.84);
  font-size: 0.82rem;
  font-weight: 900;
  line-height: 1.15;
  text-align: center;
}

.title-block {
  min-width: 0;
}

.eyebrow,
.panel-kicker {
  margin: 0;
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin-bottom: 4px;
  font-size: 2rem;
  line-height: 1.08;
}

h2,
h3 {
  line-height: 1.18;
}

.subtitle {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.96rem;
}

.fact-chip {
  display: grid;
  gap: 3px;
  min-width: 136px;
  padding: 10px 12px;
  border-left: 4px solid var(--green);
  border-radius: var(--radius);
  background: #edf9f2;
  color: #0b5d3b;
}

.fact-chip span {
  font-size: 0.78rem;
}

.fact-chip strong {
  font-size: 0.98rem;
}

.notice-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  align-items: center;
  margin-top: 14px;
  padding: 10px 14px;
  color: #60420c;
  background: #fff8e8;
  border-color: rgba(240, 163, 26, 0.34);
  font-size: 0.92rem;
  box-shadow: none;
}

.notice-strip strong {
  color: #7a4300;
}

.view-switcher {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 14px;
  padding: 9px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 10px 24px rgba(16, 32, 51, 0.09);
}

.view-switch-button {
  min-height: 44px;
  padding: 0 14px;
  color: #173456;
  background: #edf5fb;
  white-space: nowrap;
}

.view-switch-button.is-active {
  color: #fff;
  background: var(--blue);
  box-shadow: 0 10px 24px rgba(11, 99, 182, 0.24);
}

.sandbox-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 16px;
  align-items: start;
  margin-top: 16px;
}

.stage-column {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.scene-card {
  padding: 18px;
  overflow: hidden;
}

.scene-head {
  display: flex;
  gap: 18px;
  align-items: start;
  justify-content: space-between;
  margin-bottom: 14px;
}

.scene-head h2 {
  margin: 4px 0 8px;
  font-size: 1.72rem;
}

.scene-head p:last-child {
  margin-bottom: 0;
  color: var(--muted);
  font-weight: 800;
}

.scene-score {
  display: grid;
  min-width: 148px;
  gap: 2px;
  padding: 12px 14px;
  border: 1px solid rgba(18, 183, 207, 0.26);
  border-radius: var(--radius);
  background: #f0fbfc;
  color: #0f6371;
}

.scene-score span {
  font-size: 0.82rem;
  font-weight: 900;
}

.scene-score strong {
  font-size: 2rem;
  line-height: 1;
}

.scene-frame {
  position: relative;
  overflow: hidden;
  min-height: 420px;
  aspect-ratio: 16 / 9;
  border: 1px solid rgba(16, 32, 51, 0.12);
  border-radius: var(--radius);
  background: #dceaf2;
  isolation: isolate;
}

.scene-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(10, 27, 45, 0.02), rgba(10, 27, 45, 0.18)),
    linear-gradient(90deg, rgba(255, 255, 255, 0.08) 0%, transparent 22%, transparent 78%, rgba(255, 255, 255, 0.08) 100%);
}

.scene-image {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.effect-layer,
.pin-layer,
.route-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.route-layer {
  z-index: 3;
  display: none;
}

.route-path {
  fill: none;
  stroke: var(--active-color);
  stroke-width: 0.92;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 8 7;
  filter: drop-shadow(0 0 4px var(--active-glow));
  opacity: 0.9;
}

.route-path.is-active {
  animation: routeDash 1.9s linear infinite;
}

.route-path.is-ghost {
  opacity: 0.18;
  animation: none;
}

.route-air {
  stroke: var(--cyan);
}

.route-energy {
  stroke: var(--amber);
}

.route-water {
  stroke: var(--water);
  stroke-width: 1.05;
}

.route-crop {
  stroke: var(--field);
  stroke-width: 1.05;
}

.route-field {
  stroke: var(--green);
  stroke-width: 1.05;
}

.route-trace {
  stroke: var(--trace);
  stroke-width: 1.05;
}

.route-safety {
  stroke: var(--red);
  stroke-width: 1.05;
}

.route-data {
  stroke: var(--violet);
}

.route-elevator {
  stroke: var(--green);
  stroke-width: 1.05;
}

.pin {
  position: absolute;
  left: var(--x);
  top: var(--y);
  z-index: 4;
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 3px solid rgba(255, 255, 255, 0.86);
  border-radius: 50%;
  background: rgba(16, 32, 51, 0.58);
  color: #fff;
  font-weight: 900;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.22), 0 0 22px rgba(16, 32, 51, 0.28);
}

.pin.is-active {
  background: var(--active-color);
  box-shadow: 0 0 0 8px color-mix(in srgb, var(--active-color) 20%, transparent), 0 0 28px var(--active-glow);
  animation: pinPulse 1.4s ease-in-out infinite;
}

.pin.is-complete {
  background: var(--green);
}

.pin-label {
  position: absolute;
  left: var(--lx);
  top: var(--ly);
  z-index: 5;
  display: grid;
  max-width: min(310px, 36%);
  gap: 3px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-left: 5px solid var(--active-color);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 16px 30px rgba(16, 32, 51, 0.2);
  transform: translate(-50%, -50%);
  backdrop-filter: blur(8px);
}

.pin-label span {
  color: var(--active-color);
  font-size: 0.82rem;
  font-weight: 900;
}

.pin-label strong {
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.25;
}

.live-note {
  position: absolute;
  left: 22px;
  bottom: 22px;
  z-index: 5;
  width: min(460px, calc(100% - 44px));
  padding: 16px 18px;
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-left: 5px solid var(--active-color);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 18px 38px rgba(16, 32, 51, 0.2);
  backdrop-filter: blur(8px);
}

.live-note span {
  color: var(--active-color);
  font-size: 0.82rem;
  font-weight: 900;
}

.live-note strong {
  display: block;
  margin-top: 4px;
  font-size: 1.12rem;
}

.live-note p,
.live-note small {
  display: block;
  margin: 6px 0 0;
  color: #425268;
  font-weight: 800;
  line-height: 1.45;
}

.live-note small {
  color: #0b5d6a;
  font-size: 0.8rem;
}

.step-dock {
  padding: 18px;
  box-shadow: 0 12px 30px rgba(16, 32, 51, 0.1);
}

.step-head {
  display: flex;
  gap: 16px;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 12px;
}

.step-head h2 {
  margin: 3px 0 0;
  font-size: 1.58rem;
}

.step-head p:last-child {
  max-width: 620px;
  margin-bottom: 0;
  color: var(--muted);
  font-weight: 900;
}

.step-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.step-card {
  min-height: 118px;
  padding: 12px;
  border: 1px solid rgba(16, 32, 51, 0.1);
  text-align: left;
  background: #f8fbfd;
}

.step-card span {
  display: block;
  color: var(--blue);
  font-size: 0.82rem;
  font-weight: 900;
}

.step-card strong {
  display: block;
  margin-top: 8px;
  color: var(--ink);
  font-size: 1.04rem;
  line-height: 1.28;
}

.step-card small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1.42;
}

.step-card.is-active {
  border-color: color-mix(in srgb, var(--active-color) 64%, white);
  background: color-mix(in srgb, var(--active-color) 10%, white);
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--active-color) 18%, transparent);
}

.step-card.is-complete {
  border-color: rgba(24, 163, 108, 0.35);
  background: #eefaf3;
}

.operator-panel {
  display: grid;
  gap: 14px;
  padding: 18px;
  position: sticky;
  top: 12px;
}

.panel-heading h2 {
  margin: 4px 0 0;
  font-size: 1.45rem;
}

.field {
  display: grid;
  gap: 7px;
  color: #213b59;
  font-weight: 900;
}

.field select {
  min-height: 46px;
  width: 100%;
  padding: 0 12px;
  border: 1px solid #cddde7;
  border-radius: var(--radius);
  background: #f8fbfd;
  color: var(--ink);
  font-weight: 900;
}

.button-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.button-grid button {
  min-height: 48px;
  padding: 0 12px;
}

.button-grid .primary-action {
  grid-column: 1 / -1;
  color: #fff;
  background: var(--blue);
}

.metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.metric-grid article {
  min-height: 94px;
  padding: 12px;
  border: 1px solid rgba(16, 32, 51, 0.1);
  border-radius: var(--radius);
  background: #f7fbfd;
}

.metric-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
}

.metric-grid strong {
  display: block;
  margin-top: 10px;
  color: var(--ink);
  font-size: 1.34rem;
  line-height: 1;
}

.sensor-panel,
.weight-panel,
.review-card {
  border-radius: var(--radius);
}

.sensor-panel {
  padding: 14px;
  border: 1px solid rgba(11, 99, 182, 0.18);
  background: linear-gradient(180deg, #f4f9ff 0%, #ffffff 100%);
}

.sensor-head,
.weight-head {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.sensor-head h3,
.weight-head h3 {
  margin: 2px 0 0;
  font-size: 1.08rem;
}

#sensorBadge,
#weightBadge {
  padding: 6px 9px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 900;
  white-space: nowrap;
}

#sensorBadge {
  background: #e6f1ff;
  color: #0b4d90;
}

.sensor-cards {
  display: grid;
  gap: 8px;
}

.sensor-card {
  padding: 9px 10px;
  border: 1px solid rgba(16, 32, 51, 0.09);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.82);
}

.sensor-card span {
  display: block;
  color: var(--blue);
  font-size: 0.76rem;
  font-weight: 900;
}

.sensor-card strong {
  display: block;
  margin-top: 4px;
  color: #223750;
  font-size: 0.86rem;
  line-height: 1.34;
}

.sensor-fusion-text {
  margin: 10px 0 0;
  color: #405167;
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1.5;
}

.weight-panel {
  padding: 14px;
  border: 1px solid rgba(18, 183, 207, 0.22);
  background: linear-gradient(180deg, #f2fcfd 0%, #ffffff 100%);
}

#weightBadge {
  background: #e0f6f8;
  color: #106474;
}

.weight-rows {
  display: grid;
  gap: 8px;
}

.weight-row {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr) 42px;
  gap: 9px;
  align-items: center;
  font-size: 0.84rem;
  font-weight: 900;
}

.meter {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #dcebf2;
}

.meter i {
  display: block;
  width: var(--w);
  height: 100%;
  border-radius: inherit;
  background: var(--active-color);
}

.reason-text,
.review-card p {
  margin: 10px 0 0;
  color: #405167;
  font-size: 0.92rem;
  font-weight: 800;
  line-height: 1.5;
}

.review-card {
  padding: 14px;
  border: 1px solid rgba(24, 163, 108, 0.24);
  background: #f1fbf6;
}

.review-card span {
  color: #0f6c47;
  font-size: 0.82rem;
  font-weight: 900;
}

.review-card strong {
  display: block;
  margin-top: 5px;
  font-size: 1.08rem;
}

.effect-item {
  position: absolute;
  z-index: 2;
  display: block;
  pointer-events: none;
}

.effect-ring {
  left: var(--x);
  top: var(--y);
  width: var(--s, 86px);
  height: var(--s, 86px);
  border: 2px solid color-mix(in srgb, var(--active-color) 72%, white);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 28px var(--active-glow);
  animation: ringPulse 1.8s ease-in-out infinite;
}

.effect-flow {
  left: var(--x);
  top: var(--y);
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--active-color);
  box-shadow: 0 0 16px var(--active-color);
  animation: flowBlink 1.4s ease-in-out infinite;
}

.effect-tile {
  left: var(--x);
  top: var(--y);
  max-width: 190px;
  min-width: 96px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-left: 4px solid var(--active-color);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.82);
  color: #1b314d;
  font-size: 0.82rem;
  font-weight: 900;
  line-height: 1.28;
  backdrop-filter: blur(7px);
}

.sensor-tag {
  left: var(--x);
  top: var(--y);
  max-width: 130px;
  padding: 5px 8px 5px 18px;
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-left: 3px solid var(--active-color);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  color: #173456;
  font-size: 0.72rem;
  font-weight: 900;
  line-height: 1.15;
  transform: translate(-50%, -50%);
  box-shadow: 0 10px 22px rgba(16, 32, 51, 0.16);
  backdrop-filter: blur(7px);
}

.sensor-tag::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 50%;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--active-color);
  box-shadow: 0 0 10px var(--active-color);
  transform: translateY(-50%);
}

.effect-hub,
.effect-twin {
  --active-color: var(--cyan);
  --active-glow: rgba(18, 183, 207, 0.38);
}

.effect-fertigation,
.effect-rootzone {
  --active-color: var(--water);
  --active-glow: rgba(23, 166, 216, 0.38);
}

.effect-greenhouse,
.effect-phenotyping {
  --active-color: var(--field);
  --active-glow: rgba(117, 184, 67, 0.38);
}

.effect-warning {
  --active-color: var(--amber);
  --active-glow: rgba(240, 163, 26, 0.38);
}

.effect-collaboration {
  --active-color: var(--green);
  --active-glow: rgba(24, 163, 108, 0.36);
}

.effect-selfheal {
  --active-color: var(--red);
  --active-glow: rgba(217, 75, 75, 0.38);
}

.effect-traceability {
  --active-color: var(--trace);
  --active-glow: rgba(89, 103, 232, 0.34);
}

.app-shell[data-status="incident"] {
  --active-color: var(--orange);
  --active-glow: rgba(231, 111, 45, 0.45);
}

.app-shell[data-status="complete"] {
  --active-color: var(--green);
  --active-glow: rgba(24, 163, 108, 0.42);
}

@keyframes routeDash {
  to {
    stroke-dashoffset: -30;
  }
}

@keyframes pinPulse {
  0%,
  100% {
    transform: translate(-50%, -50%) scale(1);
  }
  50% {
    transform: translate(-50%, -50%) scale(1.08);
  }
}

@keyframes ringPulse {
  0%,
  100% {
    opacity: 0.44;
    transform: translate(-50%, -50%) scale(0.92);
  }
  50% {
    opacity: 0.96;
    transform: translate(-50%, -50%) scale(1.04);
  }
}

@keyframes flowBlink {
  0%,
  100% {
    opacity: 0.32;
    transform: translate(-50%, -50%) scale(0.72);
  }
  50% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.15);
  }
}

@media (max-width: 1240px) {
  .sandbox-layout {
    grid-template-columns: 1fr;
  }

  .operator-panel {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }

  .panel-heading,
  .field,
  .button-grid,
  .review-card {
    grid-column: 1 / -1;
  }

  .scene-frame {
    min-height: 360px;
  }
}

@media (max-width: 820px) {
  .app-shell {
    width: min(100% - 20px, 720px);
    padding-top: 10px;
  }

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

  .logo-slot {
    width: 76px;
    height: 58px;
  }

  h1 {
    font-size: 1.62rem;
  }

  .notice-strip {
    display: grid;
  }

  .view-switcher {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 11px;
  }

  .view-switch-button {
    flex: 0 0 auto;
  }

  .scene-card,
  .operator-panel,
  .step-dock {
    padding: 12px;
  }

  .scene-head,
  .step-head {
    display: grid;
  }

  .scene-score {
    min-width: 0;
    width: 100%;
  }

  .scene-frame {
    min-height: 0;
  }

  .pin {
    width: 28px;
    height: 28px;
    font-size: 0.78rem;
  }

  .pin-label {
    max-width: 58%;
    padding: 8px 9px;
  }

  .pin-label strong {
    font-size: 0.86rem;
  }

  .live-note {
    left: 10px;
    right: 10px;
    bottom: 10px;
    width: auto;
    padding: 10px 12px;
  }

  .live-note strong {
    font-size: 0.96rem;
  }

  .live-note p {
    font-size: 0.84rem;
  }

  .sensor-tag {
    font-size: 0.66rem;
    max-width: 112px;
  }

  .step-cards {
    grid-template-columns: 1fr;
  }

  .operator-panel {
    grid-template-columns: 1fr;
  }

  .sensor-panel,
  .weight-panel {
    grid-column: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
