:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-2: #eef3f8;
  --text: #101820;
  --muted: #5b6878;
  --border: #d7dee8;
  --blue: #2869ff;
  --cyan: #19b6c7;
  --green: #14965b;
  --red: #d03a3a;
  --amber: #b7791f;
  --violet: #7147d8;
  --shadow: 0 14px 40px rgba(25, 42, 70, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

.shell {
  min-height: 100vh;
  padding: 24px;
  display: flex;
  flex-direction: column;
}

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

h1, h2, p { margin: 0; }
h1 { font-size: 28px; line-height: 1.1; font-weight: 760; }
h2 { font-size: 15px; line-height: 1.2; font-weight: 760; }
p { color: var(--muted); margin-top: 6px; font-size: 14px; }

.connection {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  font-size: 13px;
  color: var(--muted);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--amber);
}
.dot.online { background: var(--green); }
.dot.offline { background: var(--red); }

.status-grid {
  order: 1;
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.metric.wide {
  display: none;
}

.insight-strip {
  order: 2;
  display: grid;
  grid-template-columns: minmax(280px, 1.2fr) minmax(360px, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}
.insight-main,
.insight-facts {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.insight-main {
  min-height: 72px;
  padding: 14px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 6px 12px;
}
.insight-main strong {
  min-width: 0;
  font-size: 18px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}
.insight-main > span:last-child {
  grid-column: 2;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.insight-facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  min-height: 72px;
}
.insight-facts div {
  min-width: 0;
  padding: 13px 14px;
  border-left: 1px solid var(--border);
}
.insight-facts div:first-child { border-left: 0; }
.insight-facts span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
  margin-bottom: 8px;
}
.insight-facts strong {
  display: block;
  font-size: 17px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.control-panel {
  order: 5;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.glossary-panel {
  order: 7;
  display: grid;
  grid-template-columns: minmax(220px, 0.38fr) minmax(0, 1fr);
  gap: 14px;
  margin-bottom: 14px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.glossary-panel dl {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}
.glossary-panel dl div {
  min-width: 0;
  padding: 10px;
  background: #fbfcfe;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.glossary-panel dt {
  margin: 0 0 5px;
  font-size: 12px;
  font-weight: 760;
  color: var(--text);
}
.glossary-panel dd {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.38;
}
.filter-group {
  display: none;
  grid-template-columns: repeat(4, minmax(112px, 0.7fr)) minmax(180px, 1.2fr) minmax(148px, 0.82fr);
  gap: 10px;
  flex: 1 1 auto;
}
.filter-group label {
  position: relative;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.filter-group label span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
}
.filter-group select,
.filter-group input {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfcfe;
  color: var(--text);
  padding: 0 10px;
  font: inherit;
  font-size: 12px;
}
.toggle-control {
  justify-content: end;
}
.toggle-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.toggle-control strong {
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfcfe;
  color: var(--muted);
  padding: 0 10px;
  font-size: 12px;
  font-weight: 760;
  cursor: pointer;
}
.toggle-control strong::before {
  content: "";
  width: 30px;
  height: 18px;
  border-radius: 999px;
  background: #d9e1ec;
  box-shadow: inset 0 0 0 1px rgba(16, 24, 32, 0.08);
}
.toggle-control strong::after {
  content: "";
  position: absolute;
  right: calc(100% - 39px);
  bottom: 8px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 4px rgba(16, 24, 32, 0.24);
  transition: transform 160ms ease;
}
.toggle-control input:checked + strong {
  border-color: rgba(40, 105, 255, 0.35);
  color: #123fbd;
  background: #e8efff;
}
.toggle-control input:checked + strong::before {
  background: var(--blue);
}
.toggle-control input:checked + strong::after {
  transform: translateX(12px);
}
.action-group {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}
.action-group button,
.row-action {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  min-height: 34px;
  padding: 0 11px;
  font-size: 12px;
  font-weight: 760;
  color: var(--text);
  cursor: pointer;
}
.action-group button:hover,
.row-action:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.scenario-panel {
  order: 3;
  display: grid;
  grid-template-columns: minmax(190px, 0.26fr) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  margin-bottom: 14px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.scenario-copy p {
  max-width: 420px;
}
.latest-evidence {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 0.7fr 1.45fr 1.18fr 0.55fr 0.7fr 0.76fr 0.74fr;
  gap: 8px;
}
.latest-evidence div {
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfcfe;
}
.latest-evidence span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
  margin-bottom: 4px;
}
.latest-evidence strong {
  display: block;
  font-size: 12px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.scenario-form {
  display: grid;
  grid-template-columns: minmax(260px, 1.1fr) minmax(220px, 0.8fr) minmax(160px, 0.55fr) minmax(210px, 0.7fr);
  gap: 12px;
  align-items: stretch;
}
.scenario-form label {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.scenario-form label span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
}
.scenario-stage {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: #fbfcfe;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.scenario-stage > span,
.scenario-advanced summary {
  color: #344255;
  font-size: 12px;
  font-weight: 800;
}
.scenario-choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.scenario-form .scenario-choice {
  min-height: 62px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 4px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  text-align: left;
  white-space: normal;
}
.scenario-form .scenario-choice strong {
  font-size: 12px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.scenario-form .scenario-choice small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
}
.scenario-form .scenario-choice.active {
  border-color: rgba(40, 105, 255, 0.48);
  background: #eef4ff;
  color: #123fbd;
}
.scenario-preview {
  background: #f7fbff;
}
.scenario-schema-preview {
  background: #f9fbfd;
}
.scenario-schema-preview pre {
  width: 100%;
  max-height: 320px;
  margin: 0;
  padding: 12px;
  overflow: auto;
  border: 1px solid #ccd7e5;
  border-radius: 8px;
  background: #101820;
  color: #e6edf5;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 11px;
  line-height: 1.45;
  white-space: pre;
}
.scenario-kind-field {
  grid-column: span 1;
}
.scenario-kind-field strong {
  min-height: 32px;
  display: block;
  padding: 8px 10px;
  color: #344255;
  background: #edf4ff;
  border: 1px solid rgba(40, 105, 255, 0.16);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 640;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
#scenario-steps {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 18px;
  color: #243244;
  font-size: 12px;
  line-height: 1.35;
}
#scenario-steps li::marker {
  color: var(--blue);
  font-weight: 800;
}
.room-select-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.room-select-grid label {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.scenario-form select,
.scenario-form input {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfcfe;
  color: var(--text);
  padding: 0 10px;
  font: inherit;
  font-size: 12px;
}
.scenario-form button,
.ops-form button {
  width: 100%;
  min-height: 34px;
  border: 1px solid rgba(40, 105, 255, 0.32);
  background: #2869ff;
  color: #ffffff;
  border-radius: 8px;
  padding: 0 13px;
  font-size: 12px;
  font-weight: 760;
  cursor: pointer;
  white-space: nowrap;
}
.scenario-form button.secondary-action,
.ops-form button {
  border-color: var(--border);
  background: var(--surface);
  color: var(--text);
}
.scenario-form button.danger-action {
  border-color: rgba(208, 58, 58, 0.32);
  background: #fdecec;
  color: var(--red);
}
.scenario-actions,
.scenario-dispatch {
  justify-content: space-between;
}
.scenario-dispatch small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}
.scenario-dispatch small.ok {
  color: var(--green);
}
.scenario-dispatch small.error {
  color: var(--red);
}
.scenario-advanced {
  grid-column: 1 / -1;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfcfe;
  padding: 10px 12px;
}
.scenario-advanced summary {
  cursor: pointer;
}
.advanced-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
  margin-top: 10px;
}

.ops-panel {
  order: 6;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  margin-bottom: 14px;
}
.ops-card {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(180px, 0.8fr) minmax(0, 1.2fr);
  gap: 12px;
  align-items: end;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.ops-form {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto;
  gap: 10px;
  align-items: end;
}
.ops-form.sla-form {
  grid-template-columns: repeat(3, minmax(96px, 1fr)) auto;
}
.ops-form label {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.ops-form label span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
}
.ops-form select,
.ops-form input {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfcfe;
  color: var(--text);
  padding: 0 10px;
  font: inherit;
  font-size: 12px;
}

.metric, .panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric {
  min-height: 78px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.metric span, .panel-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}
.metric strong {
  font-size: 19px;
  line-height: 1.2;
}
.metric.wide strong {
  font-size: 13px;
  overflow-wrap: anywhere;
}

.workspace {
  order: 4;
  display: grid;
  grid-template-columns: minmax(360px, 1.12fr) minmax(320px, 0.88fr);
  grid-template-rows: minmax(360px, auto) minmax(220px, auto) minmax(220px, auto);
  gap: 14px;
}

.panel {
  min-width: 0;
  padding: 14px;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.flow-panel { grid-row: span 2; }
.timeline-panel { grid-column: span 2; }
.routine-panel,
.alerts-panel,
.queues-panel {
  display: none;
}
.run-panel,
.routine-panel,
.alerts-panel,
.requests-panel,
.queues-panel,
.verification-panel,
.evidence-panel,
.tasks-panel,
.timeline-panel {
  min-height: 260px;
}

.flow {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  min-height: 420px;
  padding: 4px;
  isolation: isolate;
}
.flow-atmosphere {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 220ms ease;
  z-index: 0;
}
.flow.active-signal .flow-atmosphere {
  opacity: 1;
}
.flow-atmosphere::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 44px;
  bottom: 76px;
  width: 76px;
  transform: translateX(-50%);
  background:
    linear-gradient(180deg, rgba(40, 105, 255, 0), rgba(40, 105, 255, 0.16), rgba(20, 150, 91, 0)),
    repeating-linear-gradient(180deg, rgba(40, 105, 255, 0.18) 0 7px, transparent 7px 18px);
  clip-path: polygon(47% 0, 53% 0, 53% 100%, 47% 100%);
  animation: route-current 1.35s linear infinite;
}
.flow-atmosphere span {
  position: absolute;
  left: 50%;
  top: 54px;
  width: 12px;
  height: 12px;
  margin-left: -6px;
  border-radius: 50%;
  background: radial-gradient(circle, #ffffff 0 18%, var(--cyan) 19% 52%, rgba(25, 182, 199, 0) 72%);
  box-shadow: 0 0 24px rgba(25, 182, 199, 0.78);
  animation: packet-flight 2.15s cubic-bezier(0.35, 0, 0.25, 1) infinite;
}
.flow-atmosphere span:nth-child(2) {
  animation-delay: 0.34s;
  background: radial-gradient(circle, #ffffff 0 18%, var(--blue) 19% 52%, rgba(40, 105, 255, 0) 72%);
}
.flow-atmosphere span:nth-child(3) {
  animation-delay: 0.78s;
  background: radial-gradient(circle, #ffffff 0 18%, var(--violet) 19% 52%, rgba(113, 71, 216, 0) 72%);
}
.flow-atmosphere span:nth-child(4) {
  animation-delay: 1.18s;
  background: radial-gradient(circle, #ffffff 0 18%, var(--green) 19% 52%, rgba(20, 150, 91, 0) 72%);
}
.source-row, .queue-row {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.queue-row {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.source-node, .flow-node, .queue-node {
  position: relative;
  min-height: 38px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 760;
  color: #253142;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease, box-shadow 180ms ease;
}
.source-node {
  cursor: default;
  font: inherit;
}
.source-node.active, .flow-node.active, .queue-node.active {
  border-color: var(--blue);
  background: #e8efff;
  color: #123fbd;
  transform: translateY(-1px);
  box-shadow: 0 0 0 3px rgba(40, 105, 255, 0.11), 0 12px 26px rgba(40, 105, 255, 0.13);
}
.source-node.active::after, .flow-node.active::after, .queue-node.active::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: inherit;
  border: 1px solid rgba(40, 105, 255, 0.45);
  animation: node-ring 1.4s ease-out infinite;
  pointer-events: none;
}
.flow-node.executor.active { border-color: var(--green); background: #e8f7ef; color: #0d6d42; }
.pipe {
  position: relative;
  z-index: 1;
  width: 2px;
  height: 14px;
  background: var(--border);
  align-self: center;
  overflow: hidden;
}
.flow.active-signal .pipe {
  background: rgba(40, 105, 255, 0.18);
  box-shadow: 0 0 18px rgba(40, 105, 255, 0.28);
}
.flow.active-signal .pipe::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 60%;
  top: -70%;
  background: linear-gradient(180deg, rgba(255,255,255,0), #2869ff, rgba(255,255,255,0));
  animation: pipe-scan 850ms linear infinite;
}
.motion-caption {
  position: relative;
  z-index: 1;
  margin-top: 4px;
  border: 1px solid rgba(40, 105, 255, 0.18);
  background: linear-gradient(135deg, rgba(232, 239, 255, 0.92), rgba(232, 247, 239, 0.82));
  border-radius: 8px;
  padding: 12px;
  min-height: 66px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
}
.motion-caption strong {
  font-size: 15px;
  line-height: 1.2;
}
.motion-caption span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.flow.burst .motion-caption {
  animation: caption-hit 560ms ease-out;
}

.task-list, .test-list, .queue-list, .timeline, .run-list, .routine-list,
.alert-list, .request-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.verification-summary {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.verification-scope {
  margin: -2px 0 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}
.verification-summary.ok {
  border-color: rgba(20, 150, 91, 0.26);
}
.verification-summary.failed {
  border-color: rgba(208, 58, 58, 0.26);
}
.verification-verdict {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.verification-verdict strong {
  min-width: 0;
  font-size: 15px;
  overflow-wrap: anywhere;
}
.verification-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.verification-grid div {
  min-height: 58px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfcfe;
}
.verification-grid span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
  margin-bottom: 5px;
}
.verification-grid strong {
  display: block;
  font-size: 13px;
  overflow-wrap: anywhere;
}
.verification-summary p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}
.workflow-step-flow {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.workflow-step-flow > span {
  color: #344255;
  font-size: 12px;
  font-weight: 800;
}
.workflow-step-flow ol {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.workflow-step-flow li {
  display: grid;
  grid-template-columns: minmax(82px, 0.7fr) minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-height: 36px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfcfe;
}
.workflow-step-flow li.completed {
  border-color: rgba(20, 150, 91, 0.32);
  background: #e8f7ef;
}
.workflow-step-flow li.running {
  border-color: rgba(40, 105, 255, 0.32);
  background: #e8efff;
}
.workflow-step-flow li span {
  font-size: 12px;
  font-weight: 800;
  color: #243244;
}
.workflow-step-flow li small {
  min-width: 0;
  color: var(--muted);
  font-size: 11px;
  overflow-wrap: anywhere;
}
.empty {
  color: var(--muted);
  font-size: 13px;
}

.row {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfe;
}
.row.latest {
  border-color: rgba(40, 105, 255, 0.45);
  background: linear-gradient(135deg, #fbfcfe, #eef4ff);
  animation: latest-row 900ms ease-out;
}
.row-main {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  font-size: 13px;
  font-weight: 760;
}
.row-main > span:first-child {
  min-width: 0;
  overflow-wrap: anywhere;
}
.row-sub {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.meaning {
  color: #314052;
}
.row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.badge {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 760;
  background: var(--surface-2);
  color: #314052;
}
.badge.ok, .badge.completed { background: #e8f7ef; color: var(--green); }
.badge.running, .badge.progress { background: #e8efff; color: var(--blue); }
.badge.failed, .badge.timeout { background: #fdecec; color: var(--red); }
.badge.queued { background: #fff6df; color: var(--amber); }
.badge.warning, .badge.busy { background: #fff6df; color: var(--amber); }
.badge.reset, .badge.event { background: #f0ecff; color: var(--violet); }
.badge.started, .badge.unknown { background: #f0ecff; color: var(--violet); }
.badge.pending { background: #fff6df; color: var(--amber); }
.badge.dispatched, .badge.dry_run { background: #e8f7ef; color: var(--green); }

.routine-row,
.request-row,
.alert-row {
  background: #f9fbfd;
  border-style: dashed;
}
.alert-row {
  border-color: rgba(183, 121, 31, 0.35);
  background: #fffaf0;
}

@media (max-width: 1060px) {
  .status-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric.wide { grid-column: span 2; }
  .insight-strip { grid-template-columns: 1fr; }
  .control-panel {
    align-items: stretch;
    flex-direction: column;
  }
  .glossary-panel { grid-template-columns: 1fr; }
  .glossary-panel dl { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-group { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .scenario-panel { grid-template-columns: 1fr; }
  .scenario-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .latest-evidence { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .scenario-kind-field { grid-column: auto; }
  .scenario-form button { width: 100%; }
  .advanced-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ops-panel { grid-template-columns: 1fr; }
  .ops-card { grid-template-columns: 1fr; }
  .ops-form.sla-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: none;
  }
  .flow-panel, .timeline-panel { grid-column: auto; grid-row: auto; }
}

@media (max-width: 620px) {
  .shell { padding: 14px; }
  .topbar { flex-direction: column; }
  .connection { width: 100%; flex-wrap: wrap; }
  .status-grid { grid-template-columns: 1fr; }
  .metric.wide { grid-column: auto; }
  .insight-main { grid-template-columns: 1fr; }
  .insight-main > span:last-child { grid-column: 1; }
  .insight-facts { grid-template-columns: 1fr; }
  .insight-facts div {
    border-left: 0;
    border-top: 1px solid var(--border);
  }
  .insight-facts div:first-child { border-top: 0; }
  .filter-group { grid-template-columns: 1fr; }
  .glossary-panel dl { grid-template-columns: 1fr; }
  .scenario-form { grid-template-columns: 1fr; }
  .scenario-choice-grid { grid-template-columns: 1fr; }
  .latest-evidence { grid-template-columns: 1fr; }
  .scenario-kind-field { grid-column: auto; }
  .advanced-grid { grid-template-columns: 1fr; }
  .ops-form,
  .ops-form.sla-form { grid-template-columns: 1fr; }
  .action-group { justify-content: stretch; }
  .action-group button { flex: 1 1 130px; }
  .source-row, .queue-row { grid-template-columns: 1fr; }
  .flow { min-height: 560px; }
}

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

@keyframes packet-flight {
  0% { transform: translate3d(-42px, 0, 0) scale(0.75); opacity: 0; }
  10% { opacity: 1; }
  25% { transform: translate3d(36px, 116px, 0) scale(1); }
  52% { transform: translate3d(-28px, 250px, 0) scale(1.08); }
  78% { transform: translate3d(32px, 384px, 0) scale(0.96); opacity: 1; }
  100% { transform: translate3d(-18px, 486px, 0) scale(0.7); opacity: 0; }
}

@keyframes route-current {
  from { background-position: 0 0, 0 0; }
  to { background-position: 0 96px, 0 96px; }
}

@keyframes pipe-scan {
  from { transform: translateY(0); }
  to { transform: translateY(260%); }
}

@keyframes node-ring {
  0% { opacity: 0.72; transform: scale(0.98); }
  100% { opacity: 0; transform: scale(1.12); }
}

@keyframes caption-hit {
  0% { transform: translateY(0) scale(1); box-shadow: none; }
  35% { transform: translateY(-2px) scale(1.01); box-shadow: 0 18px 36px rgba(40, 105, 255, 0.18); }
  100% { transform: translateY(0) scale(1); box-shadow: none; }
}

@keyframes latest-row {
  0% { transform: translateX(0); box-shadow: 0 0 0 rgba(40, 105, 255, 0); }
  30% { transform: translateX(4px); box-shadow: 0 10px 24px rgba(40, 105, 255, 0.13); }
  100% { transform: translateX(0); box-shadow: 0 0 0 rgba(40, 105, 255, 0); }
}
