:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #2563eb;
  --ok: #16a34a;
  --err: #dc2626;
  --warn: #d97706;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem;
}

.topbar {
  background: #111827;
  color: #fff;
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding-top: .75rem;
  padding-bottom: .75rem;
  flex-wrap: wrap;
}

.brand {
  font-weight: 700;
  letter-spacing: .02em;
}

.topbar nav {
  display: flex;
  gap: 1rem;
  flex: 1;
}

.topbar a {
  color: #d1d5db;
  text-decoration: none;
  padding: .25rem .5rem;
  border-radius: .375rem;
}

.topbar a:hover, .topbar a.active {
  color: #fff;
  background: rgba(255, 255, 255, .12);
}

.target {
  font-size: .8rem;
  padding: .2rem .6rem;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
}

/* Einheitlich Blau: Ziel-Status (Sandbox/Production) wird über den Text transportiert, nicht über Grün/Rot. */
.target-production {
  background: var(--accent);
}

main {
  padding: 3rem 1rem 3rem;
}

.grid {
  display: grid;
  gap: 1rem;
  margin-bottom: 1rem;
}

.grid-cards {
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.grid-charts {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: .75rem;
  padding: 1.25rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
}

.card h2 {
  margin: 0 0 .75rem;
  font-size: 1.05rem;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: .25rem;
}

.stat-label {
  color: var(--muted);
  font-size: .85rem;
}

.stat-value {
  font-size: 1.75rem;
}

.card-warn .stat-value {
  color: var(--err);
}

.empty {
  text-align: center;
  padding: 2.5rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: .5rem;
  font-size: .9rem;
}

th, td {
  text-align: left;
  padding: .5rem .6rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  color: var(--muted);
  font-weight: 600;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .03em;
}

.num {
  text-align: right;
}

.badge {
  display: inline-block;
  padding: .1rem .55rem;
  border-radius: 999px;
  font-size: .78rem;
  color: #fff;
  white-space: nowrap;
}

.badge-success {
  background: var(--ok);
}

.badge-error {
  background: var(--err);
}

.badge-skipped {
  background: var(--muted);
}

.badge-dummy {
  background: #d97706;
}

.badge-live {
  background: var(--ok);
}

.hint {
  background: #fffbeb;
  border: 1px solid #fcd34d;
  color: #92400e;
  padding: .6rem .9rem;
  border-radius: .5rem;
  font-size: .88rem;
}

select, input[type="time"], input[type="text"], input[type="url"], input[type="password"] {
  padding: .35rem .5rem;
  border: 1px solid var(--line);
  border-radius: .4rem;
  background: #fff;
  color: var(--text);
  font-size: .88rem;
}

fieldset.api-env {
  border: 1px solid var(--line);
  border-radius: .5rem;
  padding: .75rem 1rem 1rem;
  margin: 0 0 1rem;
}

.api-system {
  margin: 1.5rem 0 .5rem;
  font-size: 1rem;
}

fieldset.api-env legend {
  font-weight: 600;
  font-size: .9rem;
  padding: 0 .4rem;
}

input[type="text"], input[type="url"], input[type="password"] {
  flex: 1;
  min-width: 220px;
}

button[disabled] {
  opacity: .5;
  cursor: not-allowed;
}

.btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: .5rem;
  padding: .5rem 1rem;
  font-size: .9rem;
  cursor: pointer;
  text-decoration: none;
}

.btn:hover {
  filter: brightness(1.1);
}

.btn-secondary {
  background: #e5e7eb;
  color: var(--text);
}

.flash {
  padding: .6rem 1rem;
  border-radius: .5rem;
  margin: 0 0 1rem;
}

.flash-ok {
  background: #dcfce7;
  color: #166534;
}

.flash-err {
  background: #fee2e2;
  color: #991b1b;
}

.row {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .3rem 0;
}

.meta {
  color: var(--muted);
  font-size: .85rem;
}

.warn {
  color: var(--warn);
  font-size: .85rem;
}

code {
  background: #f3f4f6;
  padding: .1rem .3rem;
  border-radius: .25rem;
  font-size: .8em;
  word-break: break-all;
}

.footer {
  color: var(--muted);
  font-size: .8rem;
  padding-bottom: 2rem;
}

canvas {
  max-height: 260px;
}

/* ── Sync-Fluss (Dashboard) ─────────────────────────────── */
.page-title {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
}

.topbar nav a {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
}

/* Icon-only Nav-Link (Konfiguration): ohne Text größere Klickfläche */
.topbar nav a.nav-icon {
  padding: .25rem .75rem;
}

.flow-card {
  margin-bottom: 1rem;
}

.flow {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 1.75rem;
  align-items: center;
  margin: 1.25rem 0;
  min-height: 220px;
}

.flow-lines {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.flow-line {
  fill: none;
  stroke: #d1d5db;
  stroke-width: 2;
}

.flow-line.is-active {
  stroke: var(--accent);
  stroke-width: 3;
}

/* Production-Linien wie alle aktiven Linien: Einheits-Blau statt Rot. */
.flow-line.is-prod {
  stroke: var(--accent);
}

.flow-line.is-animated {
  stroke-dasharray: 7 9;
  animation: flow-dash 1.2s linear infinite;
}

@keyframes flow-dash {
  to {
    stroke-dashoffset: -32;
  }
}

.flow-col {
  display: flex;
  flex-direction: column;
  gap: .6rem;
  z-index: 1;
}

.flow-col h3 {
  margin: 0;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
}

.flow-node {
  display: flex;
  align-items: center;
  gap: .5rem;
  width: 100%;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: .6rem;
  padding: .55rem .75rem;
  font-size: .9rem;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
  transition: border-color .15s, opacity .15s, box-shadow .15s;
}

.flow-node.is-off {
  opacity: .55;
}

.flow-node:hover {
  box-shadow: 0 1px 4px rgba(0, 0, 0, .12);
}

.flow-node-source.is-on {
  border-color: var(--accent);
  color: var(--text);
}

.flow-node.is-on .node-dot {
  background: var(--accent);
  border-color: var(--accent);
}

/* Selektierten Knoten einheitlich Blau (Akzent-Token) – keine grünen/roten Sonderfarben mehr. */
.flow-node-target.target-sandbox.is-on {
  border-color: var(--accent);
  color: var(--text);
}

.flow-node-target.target-sandbox.is-on .node-dot {
  background: var(--accent);
  border-color: var(--accent);
}

.flow-node-target.target-production.is-on {
  border-color: var(--accent);
  color: var(--text);
}

.flow-node-target.target-production.is-on .node-dot {
  background: var(--accent);
  border-color: var(--accent);
}

.node-dot {
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--muted);
  background: #fff;
}

.node-label {
  flex: 1;
}

.node-state {
  font-size: .75rem;
  color: var(--muted);
}

.node-count {
  font-size: .7rem;
  background: #fef3c7;
  color: #92400e;
  border-radius: 999px;
  padding: .05rem .45rem;
}

.flow-hub {
  z-index: 1;
  width: 118px;
  height: 118px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .15rem;
  border: 3px solid var(--line);
  background: #fff;
  color: var(--muted);
  transition: background .3s, color .3s, border-color .3s, box-shadow .3s;
}

.flow-hub.is-idle {
  border-color: #cbd5e1;
  color: var(--muted);
  background: #f8fafc;
}

.flow-hub.is-running {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  animation: hub-pulse 1.4s ease-in-out infinite;
}

.flow-hub.is-dry {
  border-color: var(--warn);
  background: #fffbeb;
  color: var(--warn);
  animation: hub-pulse 1.4s ease-in-out infinite;
}

.hub-icon {
  width: 40px;
  height: 40px;
}

.flow-hub.is-running .hub-icon,
.flow-hub.is-dry .hub-icon {
  animation: hub-spin 1.1s linear infinite;
}

@keyframes hub-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes hub-pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(37, 99, 235, .35);
  }
  50% {
    box-shadow: 0 0 0 14px rgba(37, 99, 235, 0);
  }
}

.hub-label {
  font-size: .78rem;
  font-weight: 600;
}

.flow-status {
  font-size: .78rem;
  padding: .2rem .6rem;
  border-radius: 999px;
  color: #fff;
}

.flow-status-idle {
  background: var(--muted);
}

.flow-status-running {
  background: var(--accent);
}

.flow-start {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .4rem;
  margin-top: .5rem;
}

.flow-start .btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
}

/* ── Modal ────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  max-width: 430px;
  width: calc(100% - 2rem);
}

.modal-step[hidden] {
  display: none;
}

.modal h3 {
  margin: 0 0 .5rem;
}

.modal-danger-title {
  color: var(--err);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: .5rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.btn-start {
  background: var(--accent);
}

.btn-danger {
  background: var(--err);
}

.btn-gated[disabled] {
  opacity: .6;
  cursor: wait;
}

.modal-hint {
  margin: .75rem 0 0;
}

.flow-stage {
  position: relative;
}

.flow-node.is-pending {
  opacity: .65;
  cursor: wait;
}

.flow-node.is-pending .node-dot {
  border-top-color: var(--accent);
  animation: node-spin .8s linear infinite;
}

@keyframes node-spin {
  to {
    transform: rotate(360deg);
  }
}

.flow-toast-area {
  position: absolute;
  left: 50%;
  bottom: .4rem;
  transform: translateX(-50%);
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .35rem;
  max-width: min(100%, 480px);
  pointer-events: none;
}

.flow-toast {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: var(--err);
  font-size: .8rem;
  padding: .4rem .75rem;
  border-radius: .5rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .12);
  text-align: center;
}

.flow-toast.is-hidden {
  opacity: 0;
  transition: opacity .35s;
}

.flow-info {
  margin-top: 1rem;
  font-size: .78rem;
  color: var(--muted);
}

.flow-info summary {
  cursor: pointer;
  font-weight: 600;
}

.flow-info p {
  margin: .35rem 0;
}

.dummy-mode-select {
  max-width: 100%;
  margin-top: .35rem;
  font-size: .75rem;
  padding: .2rem .4rem;
  border: 1px solid var(--line);
  border-radius: .4rem;
  background: #fff;
  color: var(--text);
}

.flow-col select {
  max-width: 100%;
}

