:root {
    --bg: #0e1116;
    --panel: #161b22;
    --panel-2: #1c2230;
    --line: #2a313c;
    --text: #d7dce2;
    --muted: #8b95a3;
    --accent: #4ea1ff;
    --active: #3fb950;
    --passive: #d29922;
    --declared: #6e7681;
    --remote: #bc8cff;
    --flash: #ffd33d;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font: 14px/1.45 "Segoe UI", system-ui, sans-serif;
}

header {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 10px 18px;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
}

.brand { font-size: 17px; font-weight: 700; letter-spacing: .3px; }
.brand span { color: var(--accent); }

.status { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--declared); transition: background .3s; }
.dot.up { background: var(--active); box-shadow: 0 0 8px var(--active); }
.dot.down { background: #f85149; }

.meta { margin-left: auto; color: var(--muted); font-size: 12px; }

.btn-reset {
    background: var(--panel-2); color: var(--text);
    border: 1px solid var(--line); border-radius: 6px;
    padding: 6px 12px; font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn-reset:hover { border-color: #f85149; color: #f85149; }

main {
    display: grid;
    grid-template-columns: 1fr 360px;
    height: calc(100% - 53px);
}

#graph { position: relative; border-right: 1px solid var(--line); }
#cy { position: absolute; inset: 0; }

.legend {
    position: absolute;
    left: 14px;
    bottom: 12px;
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    background: rgba(22, 27, 34, .85);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 7px 12px;
    font-size: 12px;
    color: var(--muted);
}
.legend span { display: flex; align-items: center; gap: 6px; }
.sw { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.sw.local { background: var(--accent); }
.sw.remote { background: var(--remote); }
.sw.active { background: var(--active); border-radius: 50%; }
.sw.passive { background: var(--passive); border-radius: 50%; }
.sw.declared { background: var(--declared); border-radius: 50%; }

#side { background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
.panel-title {
    padding: 11px 16px;
    font-weight: 600;
    border-bottom: 1px solid var(--line);
    color: var(--text);
}

#log { overflow-y: auto; padding: 8px 0; flex: 1; min-height: 0; }

#cmd { border-top: 1px solid var(--line); padding: 10px 14px 12px; background: var(--panel-2); }
.cmd-title { font-size: 12px; font-weight: 600; color: var(--text); margin-bottom: 7px; }
.cmd-row { display: flex; gap: 6px; margin-top: 6px; }
#cmd input {
    background: var(--bg); color: var(--text);
    border: 1px solid var(--line); border-radius: 6px;
    padding: 6px 8px; font-size: 12px; width: 100%;
}
#cmd input:focus { outline: none; border-color: var(--accent); }
#cmdSend {
    background: var(--accent); color: #06121f; border: none; border-radius: 6px;
    padding: 6px 14px; font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
#cmdSend:hover { filter: brightness(1.08); }
#cmdHint { color: var(--muted); font-size: 11px; margin-top: 7px; }
.evt {
    padding: 7px 16px;
    border-bottom: 1px solid var(--panel-2);
    animation: fadein .25s ease;
}
.evt .row1 { display: flex; align-items: baseline; gap: 8px; }
.evt .ts { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.evt .type { color: var(--accent); font-size: 11px; font-weight: 600; }
.evt .hop { margin-top: 2px; font-size: 13px; }
.evt .hop b { color: var(--text); }
.evt .arrow { color: var(--muted); margin: 0 6px; }
.evt .summary { color: var(--muted); margin-top: 2px; font-size: 12px; }

@keyframes fadein { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; } }
