/* relay-panel — 深海配线架.
   信号青 on 海军蓝,数据一律等宽;健康链路会流动。 */
:root {
  --bg0: #0a0e17;
  --bg1: #0f1522;
  --bg2: #161e30;
  --bg3: #1b2438;
  --line: #263252;
  --line-soft: #1d2740;
  --fg: #e9eef9;
  --dim: #8391ad;
  --faint: #55617d;
  --sig: #53e0c4;        /* signal aqua — 主强调色 */
  --sig-dim: rgba(83, 224, 196, .14);
  --ok: #4ade80;
  --bad: #ff6b6b;
  --warn: #f0b551;
  --unknown: #47536e;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --sans: -apple-system, "PingFang SC", "Segoe UI", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
body {
  background: var(--bg0); color: var(--fg);
  font: 14px/1.55 var(--sans);
  display: flex; flex-direction: column;
}
:focus-visible { outline: 2px solid var(--sig); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--sig-dim); }

/* ---------- header ---------- */
header {
  display: flex; align-items: center; gap: 18px;
  padding: 0 20px; height: 52px; flex-wrap: wrap;
  background: var(--bg1); border-bottom: 1px solid var(--line-soft);
}
.brand { font: 700 15px/1 var(--mono); letter-spacing: .04em; user-select: none; }
.brand em { color: var(--sig); font-style: normal; margin: 0 1px; }
.brand.big { font-size: 22px; }
nav { display: flex; gap: 2px; align-self: stretch; }
.spacer { flex: 1; }

.conn {
  display: flex; align-items: center; gap: 6px;
  font: 12px var(--mono); color: var(--dim);
}
.conn i { width: 7px; height: 7px; border-radius: 50%; background: var(--bad); }
.conn.on i { background: var(--sig); box-shadow: 0 0 6px var(--sig); }
.conn.on span { color: var(--sig); }

/* ---------- buttons ---------- */
button {
  background: var(--bg3); color: var(--fg); border: 1px solid var(--line);
  border-radius: 6px; padding: 5px 12px; cursor: pointer;
  font: 13px var(--sans); transition: border-color .12s, background .12s;
}
button:hover { border-color: var(--sig); }
button.primary { background: var(--sig); border-color: var(--sig); color: #06251f; font-weight: 600; }
button.primary:hover { background: #6ae8cf; }
button.ghost { background: transparent; border-color: transparent; color: var(--dim); }
button.ghost:hover { color: var(--fg); border-color: var(--line); }
button.danger { color: var(--bad); }
button.danger:hover { border-color: var(--bad); }
button.danger.primary { background: var(--bad); border-color: var(--bad); color: #2b0808; }
button.danger.primary:hover { background: #ff8585; }
button.icon { padding: 3px 8px; font-size: 13px; line-height: 1.3; }
button:disabled { opacity: .5; cursor: default; }
button.tab {
  background: transparent; border: none; color: var(--dim);
  padding: 0 12px; border-radius: 0; align-self: stretch;
  border-bottom: 2px solid transparent; font-size: 13.5px;
}
button.tab:hover { color: var(--fg); }
button.tab.active { color: var(--fg); border-bottom-color: var(--sig); }

/* ---------- status rail ---------- */
.statusrail {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px;
  padding: 12px 20px 0;
}
.stat {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  background: var(--bg1); border: 1px solid var(--line-soft); border-radius: 8px;
  padding: 9px 14px; text-align: left; cursor: default;
}
button.stat { cursor: pointer; }
button.stat:hover { border-color: var(--line); background: var(--bg2); }
.stat-k { font-size: 12px; color: var(--dim); letter-spacing: .08em; }
.stat-v { font: 600 17px var(--mono); color: var(--fg); white-space: nowrap; }
.stat-v .unit { font-size: 11px; color: var(--dim); font-weight: 400; margin-left: 2px; }
.stat-v.alert { color: var(--bad); }
.stat-v.calm { color: var(--faint); font-weight: 400; }

/* ---------- panes ---------- */
main { flex: 1; overflow: auto; position: relative; display: flex; flex-direction: column; }
.pane { display: none; padding: 14px 20px 20px; flex: 1; min-height: 0; }
.pane.active { display: flex; flex-direction: column; }
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.chk { color: var(--dim); font-size: 12.5px; display: flex; gap: 6px; align-items: center; white-space: nowrap; }

input.filter, select.filtersel {
  background: var(--bg1); color: var(--fg); border: 1px solid var(--line-soft);
  border-radius: 6px; padding: 6px 12px; font: 13px var(--sans); min-width: 0;
}
input.filter { flex: 0 1 320px; }
input.filter:focus { border-color: var(--sig); outline: none; }
input.filter::placeholder { color: var(--faint); }

/* ---------- chips ---------- */
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: thin; padding-bottom: 2px; }
.chip {
  font: 12px var(--mono); padding: 4px 11px; border-radius: 20px; white-space: nowrap;
  border: 1px solid var(--line); background: var(--bg1); cursor: pointer; color: var(--dim);
  transition: border-color .12s, color .12s;
}
.chip:hover { border-color: var(--sig); color: var(--fg); }
.chip.active { border-color: var(--sig); color: var(--sig); background: var(--sig-dim); }
.chip .hops { color: var(--faint); }

.zoomctl { display: flex; gap: 0; }
.zoomctl button { border-radius: 0; font-family: var(--mono); padding: 4px 10px; font-size: 12.5px; }
.zoomctl button:first-child { border-radius: 6px 0 0 6px; }
.zoomctl button:last-child { border-radius: 0 6px 6px 0; }
.zoomctl button + button { border-left: none; }

/* ---------- topology ---------- */
#topo-wrap {
  flex: 1; min-height: 420px; position: relative; overflow: hidden;
  background: var(--bg1);
  background-image: radial-gradient(var(--line-soft) 1px, transparent 1px);
  background-size: 26px 26px;
  border: 1px solid var(--line-soft); border-radius: 10px;
}
#topo { width: 100%; height: 100%; display: block; cursor: grab; }
#topo.panning { cursor: grabbing; }

.legend {
  position: absolute; left: 12px; bottom: 10px; display: flex; gap: 14px;
  font: 11px var(--mono); color: var(--dim); pointer-events: none;
  background: color-mix(in srgb, var(--bg1) 82%, transparent);
  padding: 4px 10px; border-radius: 6px;
}
.legend i.lg { display: inline-block; width: 14px; height: 2px; vertical-align: middle; margin-right: 5px; }
.lg.ok { background: var(--ok); }
.lg.bad { background: var(--bad); }
.lg.unknown { background: var(--unknown); }
.lg.disabled { background: repeating-linear-gradient(90deg, var(--unknown) 0 4px, transparent 4px 8px); }

.node rect { fill: var(--bg3); stroke: var(--line); }
.node.online rect { stroke: var(--sig); }
.node.offline rect { stroke: var(--bad); stroke-dasharray: 4 3; }
.node.external rect { fill: var(--bg2); stroke: var(--faint); stroke-dasharray: 2 3; }
.node.selected rect { stroke: var(--sig); stroke-width: 2; filter: drop-shadow(0 0 6px var(--sig-dim)); }
.node text { fill: var(--fg); font: 12px var(--mono); }
.node .sub { fill: var(--dim); font-size: 10.5px; }
.node .badge-dry { fill: var(--warn); font-size: 10px; }
.node .badge-err { fill: var(--bad); font-size: 10px; }
.node { cursor: pointer; }
.node.dimmed { opacity: .25; }

.edge path.wire { fill: none; stroke-width: 2; }
.edge.ok path.wire { stroke: var(--ok); }
.edge.bad path.wire { stroke: var(--bad); }
.edge.unknown path.wire { stroke: var(--unknown); }
.edge.disabled path.wire { stroke-dasharray: 5 5; opacity: .5; }
.edge.dim { opacity: .15; }
.edge text { font: 11px var(--mono); fill: var(--dim); paint-order: stroke; stroke: var(--bg1); stroke-width: 3px; }
.edge:hover text, .edge.selected text { fill: var(--fg); }
.edge { cursor: pointer; }
.edge.selected path.wire { stroke-width: 3; }
/* 签名:健康链路上的信号流 */
.edge.ok path.flow {
  fill: none; stroke: var(--sig); stroke-width: 2; stroke-linecap: round;
  stroke-dasharray: 3 21; opacity: .9;
  animation: signal 1.6s linear infinite;
}
.edge.ok.disabled path.flow, .edge.dim path.flow { display: none; }
@keyframes signal { to { stroke-dashoffset: -24; } }
@media (prefers-reduced-motion: reduce) {
  .edge.ok path.flow { animation: none; display: none; }
}

.empty {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 6px; text-align: center;
}
.empty p { font-size: 15px; }
.empty .sub { font-size: 12.5px; color: var(--dim); margin-bottom: 10px; }
.tablewrap { position: relative; flex: 1; min-height: 200px; overflow: auto; }
.tablewrap .empty { position: static; padding: 60px 0; }

/* ---------- drawer ---------- */
.drawer {
  position: fixed; top: 52px; right: 0; bottom: 0; width: 380px; z-index: 5;
  background: var(--bg1); border-left: 1px solid var(--line);
  display: flex; flex-direction: column;
  box-shadow: -12px 0 40px rgba(0, 0, 0, .45);
  animation: slidein .16s ease-out;
}
@keyframes slidein { from { transform: translateX(24px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .drawer { animation: none; } }
.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 16px; border-bottom: 1px solid var(--line-soft);
}
.drawer-head h3 { font-size: 14px; display: flex; align-items: center; gap: 8px; min-width: 0; }
.drawer-body { padding: 14px 16px; overflow: auto; flex: 1; }
.drawer-body dl { display: grid; grid-template-columns: 88px 1fr; gap: 6px 10px; font-size: 12.5px; }
.drawer-body dt { color: var(--dim); }
.drawer-body dd { font-family: var(--mono); word-break: break-all; }
.drawer-body .row { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.drawer-body pre {
  background: var(--bg0); border: 1px solid var(--line-soft); border-radius: 6px;
  padding: 9px; font: 11px/1.5 var(--mono); overflow: auto; max-height: 240px; margin: 6px 0 10px;
}
.cfg-label {
  display: flex; align-items: center; justify-content: space-between;
  font: 11px var(--mono); color: var(--dim); letter-spacing: .08em; margin-top: 12px;
}

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
th {
  color: var(--dim); font-weight: 500; font-size: 11px; letter-spacing: .1em;
  position: sticky; top: 0; background: var(--bg0); z-index: 1;
}
.ta-r { text-align: right; }
tbody tr { transition: background .1s; }
tbody tr:hover { background: var(--bg1); }
td .mono, .mono { font-family: var(--mono); font-size: 12px; }
td .sub { color: var(--dim); font-size: 12px; }
td .actions { display: flex; gap: 6px; justify-content: flex-end; white-space: nowrap; }

.pill {
  display: inline-block; padding: 1px 8px; border-radius: 10px;
  font: 11.5px var(--mono); white-space: nowrap;
}
.pill.ok { background: rgba(74, 222, 128, .13); color: var(--ok); }
.pill.bad { background: rgba(255, 107, 107, .13); color: var(--bad); }
.pill.warn { background: rgba(240, 181, 81, .13); color: var(--warn); }
.pill.dim { background: rgba(131, 145, 173, .13); color: var(--dim); }
.pill.sig { background: var(--sig-dim); color: var(--sig); }

.rate { color: var(--sig); }

/* switch(dry-run/托管) */
.switch { position: relative; width: 34px; height: 19px; display: inline-block; cursor: pointer; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch i {
  position: absolute; inset: 0; border-radius: 10px; background: var(--bg3);
  border: 1px solid var(--line); transition: background .15s, border-color .15s;
}
.switch i::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 13px; height: 13px;
  border-radius: 50%; background: var(--dim); transition: transform .15s, background .15s;
}
.switch input:checked + i { background: var(--sig-dim); border-color: var(--sig); }
.switch input:checked + i::after { transform: translateX(15px); background: var(--sig); }
.switch input:focus-visible + i { outline: 2px solid var(--sig); outline-offset: 2px; }

/* ---------- dialogs ---------- */
dialog {
  background: var(--bg1); color: var(--fg); border: 1px solid var(--line);
  border-radius: 12px; padding: 20px 24px; width: 460px; max-width: 92vw;
}
dialog::backdrop { background: rgba(4, 7, 14, .68); backdrop-filter: blur(2px); }
dialog h3 { margin-bottom: 14px; font-size: 15px; }
dialog form { display: grid; gap: 11px; }
dialog label { display: grid; gap: 4px; font-size: 12.5px; color: var(--dim); }
dialog input, dialog select, dialog textarea {
  background: var(--bg0); color: var(--fg); border: 1px solid var(--line);
  border-radius: 6px; padding: 7px 10px; font: 13px var(--sans);
}
dialog input:focus, dialog select:focus { border-color: var(--sig); outline: none; }
dialog .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
dialog .err { color: var(--bad); font-size: 12.5px; min-height: 1em; }
dialog .hint { color: var(--warn); font-size: 12px; min-height: 0; }
dialog p.desc { color: var(--dim); font-size: 12.5px; margin-bottom: 10px; }
dialog.confirm { width: 400px; }
dialog.confirm .body { color: var(--dim); font-size: 13px; margin-bottom: 16px; line-height: 1.6; }
dialog.confirm .body b { color: var(--fg); font-family: var(--mono); }

code.cmd {
  display: block; background: var(--bg0); border: 1px solid var(--line-soft); border-radius: 6px;
  padding: 9px 10px; font: 11.5px/1.6 var(--mono); word-break: break-all; margin: 4px 0 10px;
  user-select: all;
}
.copyrow { display: flex; align-items: center; gap: 8px; }

/* ---------- toasts ---------- */
.toasts {
  position: fixed; top: 62px; right: 16px; z-index: 50;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  background: var(--bg2); border: 1px solid var(--line); border-left: 3px solid var(--sig);
  border-radius: 8px; padding: 9px 14px; font-size: 13px; max-width: 340px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .4);
  animation: toastin .18s ease-out;
}
.toast.err { border-left-color: var(--bad); }
.toast.fade { opacity: 0; transition: opacity .3s; }
@keyframes toastin { from { transform: translateY(-6px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } .toast.fade { transition: none; } }

/* ---------- login ---------- */
.login {
  position: fixed; inset: 0; z-index: 20; background: var(--bg0);
  background-image: radial-gradient(var(--line-soft) 1px, transparent 1px);
  background-size: 26px 26px;
  display: flex; align-items: center; justify-content: center;
}
.login .card {
  background: var(--bg1); border: 1px solid var(--line); border-radius: 12px;
  padding: 34px 32px; width: 340px; display: grid; gap: 12px; text-align: center;
}
.login .sub { color: var(--dim); font-size: 12.5px; margin-bottom: 6px; }
.login input {
  background: var(--bg0); color: var(--fg); border: 1px solid var(--line);
  border-radius: 6px; padding: 9px 12px; font: 13px var(--mono); text-align: center;
}
.login input:focus { border-color: var(--sig); outline: none; }
.err { color: var(--bad); font-size: 12.5px; min-height: 1em; }

.hidden { display: none !important; }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  header { gap: 10px; padding: 0 12px; }
  .statusrail { grid-template-columns: 1fr 1fr; padding: 10px 12px 0; }
  .pane { padding: 12px; }
  .drawer { width: 100%; top: 52px; }
  input.filter { flex: 1 1 100%; order: 5; }
  /* 表格转卡片 */
  table thead { display: none; }
  table, tbody, tr, td { display: block; }
  tbody tr {
    border: 1px solid var(--line-soft); border-radius: 8px; margin-bottom: 10px;
    background: var(--bg1); padding: 6px 2px;
  }
  td { border: none; padding: 5px 12px; }
  td[data-l]::before {
    content: attr(data-l); display: block; font-size: 10.5px; color: var(--faint);
    letter-spacing: .1em; margin-bottom: 1px;
  }
  td .actions { justify-content: flex-start; }
}
