:root {
  --bg: #0e1116;
  --surface: #161b22;
  --surface-2: #1c232c;
  --border: #2a313c;
  --text: #e6edf3;
  --muted: #8b97a7;
  --accent: #3fb950;      /* signal green: active relay */
  --accent-dim: #2ea043;
  --warn: #d29922;
  --danger: #f85149;
  --radius: 10px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 500px at 80% -10%, rgba(63, 185, 80, 0.06), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.shell { max-width: 1080px; margin: 0 auto; padding: 28px 22px 64px; }

/* --- Masthead + pipeline ------------------------------------------------ */
.masthead {
  display: flex; justify-content: space-between; align-items: center; gap: 24px;
  flex-wrap: wrap; padding-bottom: 22px; border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  font-size: 26px; color: var(--accent);
  width: 44px; height: 44px; display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
}
.brand h1 { margin: 0; font-size: 19px; letter-spacing: 0.2px; }
.brand-sub { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }

.pipeline {
  display: flex; align-items: stretch; gap: 6px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px 16px;
}
.node { display: flex; flex-direction: column; gap: 3px; min-width: 96px; }
.node-hub { align-items: center; }
.node-label { font-size: 12px; color: var(--text); font-weight: 600; }
.node-state {
  font-family: var(--mono); font-size: 10.5px; color: var(--muted);
  text-transform: lowercase; letter-spacing: 0.3px;
}
.node-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--muted); box-shadow: 0 0 0 0 rgba(63,185,80,0.5);
}
.node.is-live .node-dot {
  background: var(--accent);
  animation: ping 2.4s ease-out infinite;
}
.node.is-live .node-state { color: var(--accent); }
@keyframes ping {
  0% { box-shadow: 0 0 0 0 rgba(63,185,80,0.45); }
  70% { box-shadow: 0 0 0 7px rgba(63,185,80,0); }
  100% { box-shadow: 0 0 0 0 rgba(63,185,80,0); }
}
.wire {
  align-self: center; width: 40px; height: 2px; position: relative;
  background: var(--border); border-radius: 2px; overflow: hidden;
}
.wire .pulse {
  position: absolute; top: 0; left: -40%; width: 40%; height: 100%;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: flow 2s linear infinite;
}
@keyframes flow { to { left: 110%; } }

/* --- Tabs --------------------------------------------------------------- */
.tabs { display: flex; gap: 4px; margin: 22px 0 18px; border-bottom: 1px solid var(--border); }
.tab {
  background: none; border: none; color: var(--muted); cursor: pointer;
  font: inherit; font-weight: 600; padding: 10px 16px; border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--text); border-bottom-color: var(--accent); }

/* --- Panels ------------------------------------------------------------- */
.panel { display: none; }
.panel.is-active { display: block; animation: fade 0.18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; } }

.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; }
.panel-head h2 { margin: 0 0 4px; font-size: 17px; }
.muted { color: var(--muted); margin: 0; }

/* --- Buttons ------------------------------------------------------------ */
.btn {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 14px; font: inherit; font-weight: 600; cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.btn:hover { border-color: #3a434f; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary { background: var(--accent-dim); border-color: var(--accent-dim); color: #04130a; }
.btn-primary:hover { background: var(--accent); border-color: var(--accent); }
.btn-icon { padding: 6px 10px; font-size: 12px; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); }

/* --- Match mode --------------------------------------------------------- */
.match-mode { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.seg { position: relative; }
.seg input { position: absolute; opacity: 0; }
.seg span {
  display: inline-block; padding: 5px 12px; border: 1px solid var(--border);
  border-radius: 7px; color: var(--muted); cursor: pointer; font-size: 12.5px; font-weight: 600;
}
.seg input:checked + span { color: var(--accent); border-color: var(--accent-dim); background: rgba(63,185,80,0.08); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* --- Tables ------------------------------------------------------------- */
.table-wrap {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--muted); font-weight: 600; padding: 11px 16px; border-bottom: 1px solid var(--border);
}
td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,0.015); }
.cell-keyword { font-family: var(--mono); color: var(--text); font-weight: 600; }
.cell-text { color: var(--muted); max-width: 240px; }
.col-status { width: 96px; }
.col-actions { width: 120px; text-align: right; }
.col-actions .actions { display: inline-flex; gap: 6px; }

.pill {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600;
  padding: 3px 9px; border-radius: 999px; border: 1px solid var(--border);
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-on { color: var(--accent); }
.pill-off { color: var(--muted); }

.empty { padding: 28px 16px; text-align: center; color: var(--muted); }

/* --- Cards / forms ------------------------------------------------------ */
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px;
}
.card h3 { margin: 0 0 14px; font-size: 15px; }
.card hr { border: none; border-top: 1px solid var(--border); margin: 18px 0; }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
input[type="text"], input[type="password"], textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 9px 11px; font: inherit; resize: vertical;
}
input:focus, textarea:focus { outline: none; border-color: var(--accent-dim); }
.hint { display: block; margin-top: 5px; color: var(--muted); font-family: var(--mono); font-size: 11px; }

.check { display: flex; align-items: center; gap: 8px; margin: 8px 0 4px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }

.callout {
  margin-top: 12px; padding: 11px 13px; border-radius: 8px; font-family: var(--mono); font-size: 12px;
  border: 1px solid var(--border); background: var(--bg); white-space: pre-wrap; word-break: break-all;
}
.callout.ok { border-color: var(--accent-dim); color: var(--accent); }
.callout.err { border-color: var(--danger); color: var(--danger); }

/* --- Dialog ------------------------------------------------------------- */
dialog {
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 14px; padding: 22px; width: min(460px, 92vw);
}
dialog::backdrop { background: rgba(5, 8, 12, 0.6); backdrop-filter: blur(2px); }
dialog h3 { margin: 0 0 16px; font-size: 16px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* --- Toast -------------------------------------------------------------- */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  padding: 11px 18px; border-radius: 10px; font-weight: 600; font-size: 13px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.4); z-index: 50;
}
.toast.err { border-color: var(--danger); color: var(--danger); }
.toast.ok { border-color: var(--accent-dim); }

@media (max-width: 720px) {
  .cards { grid-template-columns: 1fr; }
  .pipeline { width: 100%; justify-content: space-between; }
  .cell-text { max-width: 130px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
