:root {
  --ink: #102033;
  --muted: #607086;
  --paper: #eef5f8;
  --panel: #ffffff;
  --line: #d8e6ef;
  --blue: #0b63b6;
  --cyan: #15b8d0;
  --green: #16a36a;
  --amber: #f2a31a;
  --orange: #e76f2d;
  --violet: #6d5df2;
  --red: #d94848;
  --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(242, 163, 26, 0.6);
  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%, #f5fbff 56%, #eef9f4 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.8);
  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;
}

.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(242, 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.86);
  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: stretch;
  margin-top: 16px;
}

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

.scene-card,
.operator-panel,
.step-dock {
  min-width: 0;
  overflow: hidden;
}

.scene-head,
.step-head,
.panel-heading,
.sensor-head,
.weight-head {
  display: flex;
  gap: 14px;
  justify-content: space-between;
  align-items: flex-start;
}

.scene-head {
  padding: 18px 20px 12px;
}

.scene-head h2,
.step-head h2,
.panel-heading h2 {
  margin: 3px 0 0;
  font-size: 1.55rem;
  line-height: 1.12;
}

.sensor-head h3,
.weight-head h3 {
  margin: 2px 0 0;
}

.scene-head p:not(.panel-kicker),
.step-head p:not(.panel-kicker) {
  margin: 6px 0 0;
  color: var(--muted);
  font-weight: 700;
}

.scene-score {
  display: grid;
  gap: 3px;
  min-width: 128px;
  padding: 9px 12px;
  border: 1px solid rgba(21, 184, 208, 0.3);
  border-radius: var(--radius);
  background: #eefbfc;
  color: #116476;
}

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

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

.scene-frame {
  position: relative;
  width: calc(100% - 40px);
  aspect-ratio: 16 / 9;
  margin: 0 20px 20px;
  overflow: hidden;
  border: 1px solid rgba(16, 32, 51, 0.1);
  border-radius: var(--radius);
  background: #dfeaf2;
  isolation: isolate;
}

.scene-image {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(1.02) contrast(1.02);
}

.scene-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(7, 22, 42, 0.16), transparent 32%, transparent 72%, rgba(255, 255, 255, 0.2)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), transparent 28%, rgba(7, 22, 42, 0.2));
}

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

.effect-layer {
  z-index: 2;
}

.route-layer {
  z-index: 4;
  overflow: visible;
}

.route-layer path {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.route-path {
  stroke: var(--active-color, var(--cyan));
  stroke-width: 0.36;
  stroke-dasharray: 4 4;
  opacity: 0.58;
  filter: drop-shadow(0 0 3px var(--active-glow, rgba(21, 184, 208, 0.38)));
}

.route-path.is-ghost {
  stroke: rgba(255, 255, 255, 0.72);
  stroke-width: 0.28;
  opacity: 0.46;
  filter: none;
}

.route-path.is-active {
  stroke: var(--active-color, var(--cyan));
  stroke-width: 0.48;
  opacity: 0.9;
  stroke-dasharray: 5 3;
  filter: drop-shadow(0 0 5px var(--active-glow, rgba(21, 184, 208, 0.45)));
  animation: routeDash 1.15s linear infinite;
}

.route-sync,
.route-data,
.route-auth,
.route-signal,
.route-care,
.route-secure,
.route-repair,
.route-backup {
  stroke-dasharray: 2.4 2.8;
}

.route-floor,
.route-road,
.route-handoff,
.route-air {
  stroke-dasharray: 6 3;
}

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

.route-air {
  stroke-dasharray: 2 3.5;
}

.route-backup,
.route-repair {
  stroke: var(--orange);
}

.pin {
  position: absolute;
  left: var(--x);
  top: var(--y);
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 3px solid rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  background: var(--pin-color, var(--cyan));
  color: #fff;
  font-size: 0.72rem;
  font-weight: 900;
  transform: translate(-50%, -50%);
  box-shadow:
    0 0 0 7px color-mix(in srgb, var(--pin-color, var(--cyan)) 18%, transparent),
    0 10px 24px rgba(16, 32, 51, 0.18);
  opacity: 0.72;
}

.pin.is-complete {
  opacity: 0.92;
}

.pin.is-active {
  width: 32px;
  height: 32px;
  opacity: 1;
  animation: pinPulse 1.2s ease-in-out infinite;
}

.pin-label {
  position: absolute;
  left: var(--lx);
  top: var(--ly);
  z-index: 5;
  width: min(190px, 25vw);
  padding: 8px 10px;
  border: 2px solid color-mix(in srgb, var(--active-color, var(--cyan)) 62%, white);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 14px 28px rgba(16, 32, 51, 0.16);
  transform: translate(-50%, -50%);
}

.pin-label span {
  display: block;
  color: var(--active-color, var(--cyan));
  font-size: 0.74rem;
  font-weight: 900;
}

.pin-label strong {
  display: block;
  margin-top: 3px;
  font-size: 0.9rem;
  line-height: 1.18;
}

.live-note {
  position: absolute;
  left: 18px;
  bottom: 18px;
  z-index: 6;
  width: min(390px, calc(100% - 36px));
  margin: 0;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-left: 5px solid var(--active-color, var(--cyan));
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 16px 34px rgba(16, 32, 51, 0.16);
  backdrop-filter: blur(8px);
}

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

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

.live-note p {
  margin: 4px 0 0;
  color: #33445a;
  font-size: 0.92rem;
  line-height: 1.45;
}

.live-note small {
  display: block;
  margin-top: 7px;
  color: #25415d;
  font-size: 0.78rem;
  font-weight: 900;
  line-height: 1.35;
}

.step-dock {
  padding: 16px 18px 18px;
}

.step-head {
  align-items: center;
  margin-bottom: 12px;
}

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

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

.step-card {
  min-height: 92px;
  padding: 10px;
  border: 1px solid rgba(16, 32, 51, 0.1);
  border-radius: var(--radius);
  background: #f7fbfd;
  text-align: left;
}

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

.step-card strong {
  display: block;
  margin-top: 6px;
  font-size: 0.95rem;
  line-height: 1.18;
}

.step-card small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.32;
}

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

.step-card.is-complete {
  background: #eefaf4;
}

.operator-panel {
  display: grid;
  gap: 14px;
  align-content: start;
  padding: 18px;
}

.panel-heading h2,
.weight-head h3 {
  margin: 2px 0 0;
}

.field {
  display: grid;
  gap: 6px;
  color: #203a58;
  font-weight: 900;
}

.field select {
  width: 100%;
  min-height: 48px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f7fbfd;
  color: var(--ink);
  font-weight: 800;
}

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

.button-grid button {
  min-height: 54px;
}

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

#triggerIncident {
  background: #fff0e8;
  color: #93400d;
}

.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 {
  padding: 14px;
  border: 1px solid rgba(11, 99, 182, 0.18);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #f4f9ff 0%, #ffffff 100%);
}

.sensor-head {
  align-items: center;
  margin-bottom: 10px;
}

#sensorBadge {
  padding: 6px 9px;
  border-radius: 999px;
  background: #e6f1ff;
  color: #0b4d90;
  font-size: 0.78rem;
  font-weight: 900;
  white-space: nowrap;
}

.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.78);
}

.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: 700;
  line-height: 1.5;
}

.weight-panel {
  padding: 14px;
  border: 1px solid rgba(21, 184, 208, 0.22);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #f2fcfd 0%, #ffffff 100%);
}

.weight-head {
  align-items: center;
  margin-bottom: 10px;
}

#weightBadge {
  padding: 6px 9px;
  border-radius: 999px;
  background: #e0f6f8;
  color: #106474;
  font-size: 0.78rem;
  font-weight: 900;
}

.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, var(--cyan));
}

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

.review-card {
  padding: 14px;
  border: 1px solid rgba(22, 163, 106, 0.24);
  border-radius: var(--radius);
  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: 1;
  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, var(--cyan)) 72%, white);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 28px color-mix(in srgb, var(--active-color, var(--cyan)) 28%, transparent);
  animation: ringPulse 1.8s ease-in-out infinite;
}

.effect-scan {
  inset: 8% 10%;
  border: 2px solid rgba(255, 255, 255, 0.68);
  border-radius: var(--radius);
  box-shadow: inset 0 0 50px rgba(21, 184, 208, 0.2);
}

.effect-scan::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 18%;
  height: 3px;
  background: var(--active-color, var(--cyan));
  box-shadow: 0 0 16px var(--active-color, var(--cyan));
  animation: scanMove 2.2s ease-in-out infinite;
}

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

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

.sensor-tag {
  left: var(--x);
  top: var(--y);
  max-width: 118px;
  padding: 5px 8px 5px 18px;
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-left: 3px solid var(--active-color, var(--cyan));
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  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, var(--cyan));
  box-shadow: 0 0 10px var(--active-color, var(--cyan));
  transform: translateY(-50%);
}

.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(22, 163, 106, 0.45);
}

.effect-twin {
  --active-color: var(--cyan);
}

.effect-ambient {
  --active-color: var(--violet);
}

.effect-health {
  --active-color: var(--red);
}

.effect-robot {
  --active-color: var(--green);
}

.effect-energy {
  --active-color: var(--amber);
}

.effect-mobility,
.effect-emergency {
  --active-color: var(--blue);
}

.effect-privacy {
  --active-color: var(--violet);
}

.effect-selfheal {
  --active-color: var(--orange);
}

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

@keyframes pinPulse {
  50% {
    box-shadow:
      0 0 0 12px color-mix(in srgb, var(--pin-color, var(--cyan)) 12%, transparent),
      0 10px 28px rgba(16, 32, 51, 0.2);
  }
}

@keyframes ringPulse {
  50% {
    opacity: 0.5;
    transform: translate(-50%, -50%) scale(1.12);
  }
}

@keyframes scanMove {
  50% {
    top: 78%;
  }
}

@keyframes flowBlink {
  50% {
    opacity: 0.32;
    transform: scale(1.7);
  }
}

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

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

  .panel-heading,
  .field,
  .button-grid,
  .metric-grid,
  .sensor-panel,
  .weight-panel,
  .review-card {
    grid-column: auto;
  }

  .sensor-panel,
  .weight-panel,
  .review-card {
    grid-column: 1 / -1;
  }

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

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 18px, 1740px);
    padding-top: 10px;
  }

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

  .logo-slot,
  .fact-chip {
    width: 100%;
    min-width: 0;
  }

  h1 {
    font-size: 1.62rem;
  }

  .view-switcher {
    flex-wrap: nowrap;
    overflow-x: auto;
  }

  .scene-head,
  .step-head,
  .operator-panel,
  .sensor-head,
  .weight-head {
    display: grid;
  }

  .scene-score {
    width: 100%;
  }

  .scene-frame {
    width: calc(100% - 20px);
    margin: 0 10px 10px;
  }

  .live-note {
    left: 10px;
    bottom: 10px;
    width: calc(100% - 20px);
    padding: 10px;
  }

  .pin-label {
    display: none;
  }

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

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

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