/* Self-healing exception simulation view. */

.app-shell[data-active-view="simulation"] .self-healing-view,
.app-shell[data-active-view="inbound"] .self-healing-view,
.app-shell[data-active-view="twin"] .self-healing-view,
.app-shell[data-active-view="sorting"] .self-healing-view,
.app-shell[data-active-view="packing"] .self-healing-view,
.app-shell[data-active-view="route-opt"] .self-healing-view,
.app-shell[data-active-view="multi-agent"] .self-healing-view,
.app-shell[data-active-view="v2x"] .self-healing-view,
.app-shell[data-active-view="air-ground"] .self-healing-view,
.app-shell[data-active-view="tracking"] .self-healing-view {
  display: none;
}

.app-shell[data-active-view="self-healing"] .decision-grid,
.app-shell[data-active-view="self-healing"] .insight-grid,
.app-shell[data-active-view="self-healing"] .digital-twin-view,
.app-shell[data-active-view="self-healing"] .inbound-identity-view,
.app-shell[data-active-view="self-healing"] .visual-sorting-view,
.app-shell[data-active-view="self-healing"] .flexible-packaging-view,
.app-shell[data-active-view="self-healing"] .route-optimization-view,
.app-shell[data-active-view="self-healing"] .multi-agent-dispatch-view,
.app-shell[data-active-view="self-healing"] .v2x-transport-view,
.app-shell[data-active-view="self-healing"] .air-ground-terminal-view,
.app-shell[data-active-view="self-healing"] .trusted-tracking-view {
  display: none;
}

.self-healing-view {
  margin-top: 16px;
}

.selfheal-hero {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 14px;
  padding: 16px 18px;
  border: 1px solid rgba(20, 184, 166, 0.24);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(236, 254, 255, 0.96)),
    #ffffff;
  box-shadow: 0 14px 36px rgba(9, 24, 44, 0.1);
}

.selfheal-hero h2 {
  margin-bottom: 4px;
  color: var(--ink);
  font-size: clamp(1.5rem, 2vw, 2rem);
  letter-spacing: 0;
}

.selfheal-hero p:last-child {
  margin: 0;
  color: var(--muted);
  font-weight: 750;
}

.selfheal-status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 9px 13px;
  border: 1px solid rgba(20, 184, 166, 0.34);
  border-radius: var(--radius);
  background: #ecfeff;
  color: #0f766e;
  font-weight: 950;
  white-space: nowrap;
}

.selfheal-status-pill span {
  width: 10px;
  height: 10px;
  margin-right: 8px;
  border-radius: 999px;
  background: #14b8a6;
  box-shadow: 0 0 0 6px rgba(20, 184, 166, 0.13);
}

.selfheal-status-pill.is-blocked {
  border-color: rgba(225, 75, 75, 0.28);
  background: #fff1f0;
  color: #a62626;
}

.selfheal-status-pill.is-blocked span {
  background: var(--alert);
  box-shadow: 0 0 0 6px rgba(225, 75, 75, 0.12);
}

.selfheal-layout {
  display: grid;
  grid-template-columns: minmax(760px, 1fr) 390px;
  gap: 16px;
  align-items: start;
}

.selfheal-stage-card,
.selfheal-console .panel {
  border: 1px solid rgba(9, 24, 44, 0.1);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.selfheal-stage-card {
  min-width: 0;
  padding: 16px;
}

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

.selfheal-stage-head h2,
.selfheal-console h2 {
  letter-spacing: 0;
}

.selfheal-score {
  min-width: 138px;
  padding: 11px 13px;
  border: 1px solid rgba(20, 184, 166, 0.22);
  border-radius: 8px;
  background: #f0fdfa;
}

.selfheal-score span {
  display: block;
  color: #0f766e;
  font-size: 0.82rem;
  font-weight: 850;
}

.selfheal-score strong {
  display: block;
  color: #0f766e;
  font-size: 2rem;
  line-height: 1.05;
}

.selfheal-scene {
  position: relative;
  min-height: 0;
  overflow: hidden;
  border: 1px solid rgba(9, 24, 44, 0.08);
  border-radius: 8px;
  background: #102033;
  aspect-ratio: 16 / 9.8;
  isolation: isolate;
}

.selfheal-scene::after {
  position: absolute;
  inset: 0;
  z-index: 2;
  content: "";
  background:
    linear-gradient(90deg, rgba(8, 18, 32, 0.22), transparent 40%, rgba(8, 18, 32, 0.04)),
    radial-gradient(circle at 61% 58%, rgba(239, 68, 68, 0.2), transparent 15%),
    radial-gradient(circle at 74% 48%, rgba(34, 197, 94, 0.16), transparent 24%);
  pointer-events: none;
}

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

.selfheal-svg {
  position: absolute;
  inset: 0;
  z-index: 4;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.selfheal-path,
.selfheal-link {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.92;
  filter: url("#selfHealGlow");
}

.selfheal-path-normal {
  stroke: rgba(56, 189, 248, 0.7);
  stroke-width: 6;
  stroke-dasharray: 14 18;
  marker-end: url("#selfHealArrow");
}

.selfheal-path-backup {
  stroke: rgba(34, 197, 94, 0.96);
  stroke-width: 8;
  stroke-dasharray: 1 0;
  marker-end: url("#selfHealArrow");
}

.selfheal-path-fault {
  stroke: rgba(239, 68, 68, 0.94);
  stroke-width: 6;
  stroke-dasharray: 12 12;
}

.selfheal-link {
  stroke: rgba(251, 191, 36, 0.82);
  stroke-width: 4;
  stroke-dasharray: 8 10;
}

.selfheal-pulse {
  fill: #ffffff;
  stroke: rgba(34, 197, 94, 0.75);
  stroke-width: 4;
  filter: url("#selfHealGlow");
}

.selfheal-scene.waiting .selfheal-path-backup,
.selfheal-scene.waiting .selfheal-path-fault,
.selfheal-scene.waiting .selfheal-link,
.selfheal-scene.waiting .selfheal-pulse {
  opacity: 0.2;
}

.selfheal-scene.selfheal-listen .selfheal-path-fault,
.selfheal-scene.selfheal-diagnose .selfheal-path-fault,
.selfheal-scene.selfheal-isolate .selfheal-path-fault,
.selfheal-scene.selfheal-blocked .selfheal-path-fault {
  opacity: 1;
  animation: selfhealDash 1.25s linear infinite;
}

.selfheal-scene.selfheal-reroute .selfheal-path-backup,
.selfheal-scene.selfheal-verify .selfheal-path-backup,
.selfheal-scene.selfheal-learn .selfheal-path-backup {
  animation: selfhealDash 1.6s linear infinite;
}

.selfheal-scene.selfheal-learn .selfheal-path-normal {
  opacity: 0.34;
}

@keyframes selfhealDash {
  to {
    stroke-dashoffset: -44;
  }
}

.selfheal-fault-zone {
  position: absolute;
  z-index: 5;
  left: 51%;
  top: 48%;
  display: grid;
  place-items: center;
  width: 150px;
  height: 86px;
  border: 2px solid rgba(239, 68, 68, 0.82);
  border-radius: 14px;
  background: rgba(127, 29, 29, 0.2);
  color: #fff6f6;
  font-size: 0.82rem;
  font-weight: 950;
  opacity: 0;
  transform: rotate(-4deg);
  box-shadow: 0 0 30px rgba(239, 68, 68, 0.45);
}

.selfheal-scene.selfheal-diagnose .selfheal-fault-zone,
.selfheal-scene.selfheal-isolate .selfheal-fault-zone,
.selfheal-scene.selfheal-blocked .selfheal-fault-zone {
  opacity: 1;
}

.selfheal-card {
  position: absolute;
  z-index: 6;
  width: min(210px, 26%);
  padding: 12px 14px;
  border: 1px solid rgba(226, 232, 240, 0.76);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 16px 34px rgba(9, 24, 44, 0.2);
  backdrop-filter: blur(10px);
}

.selfheal-card p {
  margin: 0 0 4px;
  color: #0f766e;
  font-size: 0.78rem;
  font-weight: 900;
}

.selfheal-card strong {
  color: var(--ink);
  font-size: 1.05rem;
}

.selfheal-command-card {
  left: 28px;
  top: 28px;
}

.selfheal-system-card {
  right: 30px;
  top: 30px;
}

.selfheal-reason-card {
  left: 32px;
  bottom: 32px;
}

.selfheal-node {
  position: absolute;
  z-index: 6;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 2px solid rgba(255, 255, 255, 0.84);
  border-radius: 999px;
  color: white;
  font-weight: 950;
  box-shadow: 0 12px 22px rgba(9, 24, 44, 0.22);
}

.selfheal-node-sensor {
  left: 35%;
  top: 42%;
  background: #0ea5e9;
}

.selfheal-node-fault {
  left: 56%;
  top: 52%;
  background: #ef4444;
}

.selfheal-node-backup {
  left: 67%;
  top: 39%;
  background: #22c55e;
}

.selfheal-node-repair {
  left: 78%;
  top: 66%;
  background: #f59e0b;
}

.selfheal-node-verify {
  left: 86%;
  top: 28%;
  background: #7c3aed;
}

.selfheal-flow {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
  padding: 0;
  list-style: none;
}

.selfheal-flow li {
  min-height: 76px;
  padding: 10px;
  border: 1px solid rgba(20, 184, 166, 0.18);
  border-radius: 8px;
  background: #f0fdfa;
  cursor: pointer;
}

.selfheal-flow li span {
  display: block;
  margin-bottom: 4px;
  color: #0f766e;
  font-size: 0.82rem;
  font-weight: 950;
}

.selfheal-flow li strong {
  display: block;
  color: #15324a;
  font-size: 0.88rem;
  line-height: 1.35;
}

.selfheal-flow li.is-active {
  border-color: rgba(245, 158, 11, 0.54);
  background: #fff7ed;
  box-shadow: inset 0 -3px 0 rgba(245, 158, 11, 0.55);
}

.selfheal-flow li.is-done {
  border-color: rgba(34, 197, 94, 0.28);
  background: #f0fdf4;
}

.selfheal-flow li.is-error {
  border-color: rgba(239, 68, 68, 0.28);
  background: #fff1f2;
}

.selfheal-lesson-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.selfheal-lesson-grid article {
  min-height: 112px;
  padding: 12px;
  border: 1px solid rgba(9, 24, 44, 0.08);
  border-radius: 8px;
  background: #f8fafc;
}

.selfheal-lesson-grid span {
  display: block;
  margin-bottom: 6px;
  color: #0f766e;
  font-weight: 950;
}

.selfheal-lesson-grid p {
  margin: 0;
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 650;
  line-height: 1.55;
}

.selfheal-console {
  display: grid;
  gap: 12px;
}

.selfheal-console .panel {
  padding: 14px;
}

.selfheal-data-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.selfheal-data-grid article {
  min-height: 76px;
  padding: 10px;
  border: 1px solid rgba(9, 24, 44, 0.08);
  border-radius: 8px;
  background: #f8fafc;
}

.selfheal-data-grid span,
.selfheal-diagnostic span,
.selfheal-weight-row span {
  display: block;
  color: #607086;
  font-size: 0.78rem;
  font-weight: 850;
}

.selfheal-data-grid strong,
.selfheal-diagnostic strong {
  display: block;
  margin-top: 4px;
  color: var(--ink);
  font-size: 1rem;
}

.selfheal-diagnostic-head,
.selfheal-weight-head,
.selfheal-reason-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  margin-bottom: 10px;
}

.selfheal-diagnostic-head span,
.selfheal-weight-head span,
.selfheal-reason-head span {
  flex: none;
  padding: 5px 9px;
  border-radius: 999px;
  background: #ecfeff;
  color: #0f766e;
  font-size: 0.78rem;
  font-weight: 950;
}

.selfheal-weight-panel.is-risk #selfHealReasonBadge,
.selfheal-reason-panel.is-risk #selfHealPlanBadge {
  background: #fff7ed;
  color: #b45309;
}

.selfheal-weight-panel.is-blocked #selfHealReasonBadge,
.selfheal-reason-panel.is-blocked #selfHealPlanBadge {
  background: #fff1f2;
  color: #be123c;
}

.selfheal-diagnostic {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.selfheal-diagnostic article {
  min-height: 86px;
  padding: 10px;
  border: 1px solid rgba(9, 24, 44, 0.08);
  border-radius: 8px;
  background: #f8fafc;
}

.selfheal-diagnostic i {
  display: block;
  width: var(--load, 0%);
  height: 6px;
  margin-top: 9px;
  border-radius: 999px;
  background: linear-gradient(90deg, #22c55e, #38bdf8);
}

.selfheal-formula {
  margin-bottom: 10px;
  padding: 10px;
  border-radius: 8px;
  background: #f1f5f9;
  color: #24415c;
  font-size: 0.85rem;
  font-weight: 900;
}

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

.selfheal-weight-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 80px 42px;
  gap: 8px;
  align-items: center;
  min-height: 72px;
  padding: 10px;
  border: 1px solid rgba(9, 24, 44, 0.08);
  border-radius: 8px;
  background: #ffffff;
}

.selfheal-weight-row strong {
  display: block;
  margin-bottom: 4px;
  color: var(--ink);
  font-size: 0.94rem;
}

.selfheal-weight-meter {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #dbe8f3;
}

.selfheal-weight-meter i {
  display: block;
  width: var(--weight, 0%);
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #14b8a6, #22c55e);
}

.selfheal-weight-row em {
  color: #0f766e;
  font-style: normal;
  font-weight: 950;
  text-align: right;
}

.selfheal-check-list {
  display: grid;
  gap: 8px;
  margin: 0 0 10px;
  padding: 0;
  list-style: none;
}

.selfheal-check-list li {
  display: flex;
  gap: 8px;
  align-items: center;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid rgba(9, 24, 44, 0.08);
  border-radius: 8px;
  background: #f8fafc;
  color: #24415c;
  font-size: 0.9rem;
  font-weight: 850;
}

.selfheal-check-list span {
  flex: none;
  width: 11px;
  height: 11px;
  border-radius: 999px;
  background: #cbd5e1;
}

.selfheal-check-list li.is-pass span {
  background: #22c55e;
  box-shadow: 0 0 0 5px rgba(34, 197, 94, 0.12);
}

.selfheal-check-list li.is-fail span {
  background: #ef4444;
  box-shadow: 0 0 0 5px rgba(239, 68, 68, 0.12);
}

#selfHealReasonText {
  margin: 0;
  padding: 11px 12px;
  border-left: 4px solid #f59e0b;
  border-radius: 8px;
  background: #fffbeb;
  color: #8a4f00;
  font-size: 0.93rem;
  font-weight: 850;
  line-height: 1.55;
}

.selfheal-reason-panel.is-blocked #selfHealReasonText {
  border-left-color: #ef4444;
  background: #fff1f2;
  color: #991b1b;
}

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

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

  .selfheal-diagnostic-panel,
  .selfheal-weight-panel,
  .selfheal-reason-panel {
    min-width: 0;
  }
}

@media (max-width: 760px) {
  .selfheal-hero,
  .selfheal-stage-head {
    align-items: stretch;
    flex-direction: column;
  }

  .selfheal-layout {
    gap: 12px;
  }

  .selfheal-stage-card {
    padding: 10px;
  }

  .selfheal-scene {
    aspect-ratio: 9 / 12;
  }

  .selfheal-card {
    width: 45%;
    padding: 9px 10px;
  }

  .selfheal-card strong {
    font-size: 0.9rem;
  }

  .selfheal-system-card {
    right: 12px;
    top: 12px;
  }

  .selfheal-command-card {
    left: 12px;
    top: 12px;
  }

  .selfheal-reason-card {
    left: 12px;
    bottom: 12px;
  }

  .selfheal-fault-zone {
    left: 44%;
    top: 47%;
    width: 112px;
    height: 64px;
  }

  .selfheal-node {
    width: 34px;
    height: 34px;
    font-size: 0.82rem;
  }

  .selfheal-flow,
  .selfheal-lesson-grid,
  .selfheal-console,
  .selfheal-data-grid,
  .selfheal-diagnostic {
    grid-template-columns: 1fr;
  }

  .selfheal-flow li {
    min-height: 58px;
  }

  .selfheal-weight-row {
    grid-template-columns: 1fr;
  }

  .selfheal-weight-row em {
    text-align: left;
  }
}
